matlab - How to segment out the region of interest in this mask -
hi got mask following, , try segment out left panel.
i used watershed method, hope return 1 single value left panel.
d = bwdist(~mask); imshow(d,[],'initialmagnification','fit');
di = -d; di(~mask) = -inf; l = watershed(di); lrgb = label2rgb(l,'jet'); imshow(lrgb);
but instead got this, can me or have better suggestions in terms of segmentation.
referencing answer, using bwconncomp
valid approach, problem here left , right pages connected if @ spine of book. therefore, if tried suggested, entire book labelled single object, , that's not want. such, suggest separate pages first, apply labelling algorithm after you're done.
a simple morphological opening filter vertical line structuring element should trick. results, used line of length 100. have unnecessary border pixels , image rgb. therefore, i'm going convert image binary clear border:
mask = imclearborder(im2bw(imread('http://i.stack.imgur.com/xuydq.png')));
i read in image directly stackoverflow. next, we'll apply morphology talking about:
se = strel('line', 100, 90); out = imopen(mask, se);
the second input of strel
length of line given 'line'
flag you're using - denotes line structuring element, , third input orientation of line. 90 means 90 degrees, or vertical line.
next, can use bwlabel
instead of bwconncomp
... not because it's simpler use, it's faster. bwlabel
gives label matrix labels each unique object in image. objects labelled in column-major order, top bottom, left right.
this means left page given label #1.... , can extract out left page:
left_page = label == 1; imshow(left_page);
we image:
Comments
Post a Comment