私はいくつかの形態学的操作を行おうとしていたので、detectMSERFeatures を試しました。エラーが発生しています。コードの代替/修正を提案できますか。matlabで発生したエラーも引用されています
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 and extract regions
mserRegions = detectMSERFeatures(Img);
mserRegionsPixels = vertcat(cell2mat(mserRegions.PixelList)); % extract regions
% Visualize the MSER regions overlaid on the original image
figure; imshow(Img); hold on;
plot(mserRegions, 'showPixelList', true,'showEllipses',false);
title('MSER regions');
% Convert MSER pixel lists to a 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 and intersection of Gradient with MSER regions')
[label n]=bwlabel(edgeAndMSERIntersection);
figure,imshow(label2rgb(label,'jet','k','shuffle'));
次のようにエラーが発生します
Error using images.internal.imageDisplayValidateParams>validateCData (line 119)
If input is logical (binary), it must be 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);