image - ismember fails to find a number generated by bwlabel -
following post steve: http://blogs.mathworks.com/steve/2009/02/27/using-ismember-with-the-output-of-regionprops/
i wanted apply on simple case. here logical image have, has 3 objects:

this code used :
[l_t,n_t] = bwlabel(logical_image); iii = find(l_t == 2); bbb = ismember(l_t,iii); imshow(bbb); but getting in bbb empty matrix. i.e. logical image same size of original consisting entirely of 0.
n_t shows 3 objects found. max value of l_t 3. how come ismember fails find 2?
it doesn't work because iii list of indices (positions in l_t l_t == 2), , l_t number 1 3. not same doing in original example:
idx = find((100 <= area_values) & (area_values <= 1000)) here, area_values list taken regionprops of area of different regions in labelled image. has same length, n, number of regions (different values) in l. e.g. if there 10 areas in image , areas 1, 3, , 7 have areas in specified range output of idx [1 3 7].
this selects parts of l l 1, 3, or 7:
bw2 = ismember(l, idx); in case, iii list of pixel indices, not values. none of values 1, 2 or 3 (even looked ones equal 2), indices of first 3 pixels of image. therefore none of values in l_t match of values in iii.
if wanted image showing second object, enough:
bbb = l_t==2; imshow(bbb)
Comments
Post a Comment