matlab - Error in using detectMSERFeatures -


i trying morphological operation , tried detectmserfeatures. i'm getting error.can suggest alternative/correction in code.the error had in matlab quoted

img= imread('sub.png'); figure,imshow(img);title('original image') img=double(img); m1=img>40; sd = stdfilt(img, ones(3,3)); img = img.*m1; figure,imshow(img); img = bwareaopen(img,50); figure,imshow(img); % detect , extract regions mserregions = detectmserfeatures(img); mserregionspixels = vertcat(cell2mat(mserregions.pixellist));  % extract regions % visualize mser regions overlaid on original image figure; imshow(img); hold on; plot(mserregions, 'showpixellist', true,'showellipses',false); title('mser regions'); % convert mser pixel lists binary mask msermask = false(size(img)); ind = sub2ind(size(msermask), mserregionspixels(:,2),mserregionspixels(:,1)); msermask(ind) = true;  hy = fspecial('sobel'); hx = hy'; iy = imfilter(double(img), hy, 'replicate'); ix = imfilter(double(img), hx, 'replicate'); gradmag = sqrt(ix.^2 + iy.^2); edgemask=gradmag; figure, imshow(gradmag,[]), title('gradmag') edgeandmserintersection = edgemask & msermask; figure; imshowpair(edgemask, edgeandmserintersection, 'montage'); title('gradient , intersection of gradient mser regions') [label n]=bwlabel(edgeandmserintersection); figure,imshow(label2rgb(label,'jet','k','shuffle')); 

i'm getting error follows

    error using images.internal.imagedisplayvalidateparams>validatecdata (line 119) if input logical (binary), must two-dimensional.  error in images.internal.imagedisplayvalidateparams (line 27) common_args.cdata = validatecdata(common_args.cdata,image_type);  error in images.internal.imagedisplayparseinputs (line 78) common_args = images.internal.imagedisplayvalidateparams(common_args);  error in imshow (line 223)   [common_args,specific_args] = ...  error in ex7 (line 11) figure,imshow(m3); 

the error output getting can read bottom line of code, , read lines upwards goes deeper call stack. top line gives function complained , reason gives.

on line says that, logical inputs, image has 2-dimensional. if give 3-dimensional data it's assumed colour can't accept logical values - logical value binary one, can true/false (and can represented 0 , 1, makes hard tell apart normal uint or float).

the reason @ other end of error report, in bottom line:

figure,imshow(m3); 

this line code usually. line doesn't appear in code sample gave i'm guessing here first thing check properties of m3 variable. can find dimensions with

size(m3) 

the 2 likeliest scenarios a). m3 has more 2 dimensions. perhaps it's colour image that's been thresholded against scalar. alternatively b). m3 has less 2 dimensions. perhaps you've done operation on reduced dimensionality sum or mean.

if doesn't find source of error suggest paste other lines of ex7 script/function. error occurs @ line 11 @ least first 11 lines useful. if it's function helpful see code produces inputs function.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -