Wierd behaviour of 'bwareafilt' & also what algorithm does it use ?

1 view (last 30 days)
If anyone has answer of any of following , please help urgently :)
  1. What is the algorithm that 'bwareafilt' uses ?
  2. Wierd Behaviour : When the input matrix is totally black then i get following error :-(Actually i am using this function to take snapshots from webcam but when i block my webcam totally, then i get the following error )
Error using bwpropfilt (line 73)
Internal error: p must be positive.
Error in bwareafilt (line 33)
bw2 = bwpropfilt(bw, 'area', p, direction, conn);
Error in colour_reception (line 95)
Iz=bwareafilt(b,1);

Answers (1)

Image Analyst
Image Analyst on 13 Jun 2015
It most likely calls regionprops() then sorts based on area, then uses indexing or ismember() to extract only the blobs you specified.
Please attach your binary image b. Put it in a .mat file so the class and everything else doesn't change at all. Otherwise, if we don't get "b", we can't investigate your problem. But the way, just checking, b IS a binary image isn't it - it's not a gray scale or color image , right?
It could also be helpful to see your complete image segmentation algorithm so that I know how binary (logical) image "b" was created from the true color RGB image from the webcam.
  2 Comments
monu vdvdsag
monu vdvdsag on 13 Jun 2015
Edited: monu vdvdsag on 13 Jun 2015
http://ideone.com/vD7DXU Please put your palm touching webcam (so as to cover it fully) & then play this script , you will get error. If u dont cover webcam fully , magically no error anywhere!
Image Analyst
Image Analyst on 14 Jun 2015
I guess it's just a choice they made. What do you do if your user asks for the largest blob when the image is totally black/false/0 and there is not even a single blob. Do you return a black image, or do you throw an error. I guess they decided to throw an error.
Put it in a try catch
try
b = bwfiltarea(b, 1);
catch
message = sprintf('Warning: there are no blobs to return to you');
uiwait(warndlg(message));
end

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!