why do i got error with active countor edge ?

1 回表示 (過去 30 日間)
MOHAMED GILANI
MOHAMED GILANI 2021 年 12 月 9 日
コメント済み: MOHAMED GILANI 2021 年 12 月 9 日
why do i get this an error ?
I = imread('2820072.jpg');
% A = rgb2gray(I2);
bw=im2bw(I,0.4);
kernel = -1*ones(1);
kernel(2,2) = 10;
enhancedImage = imfilter(bw, kernel);
figure(6),imshow(enhancedImage);title('enhancedImage Image');
I2 = imcrop(bw,[75 68 130 112]);
figure;
imshow(I2)
title('Cropped Image')
imshow(A)
title('Original Image')
r = drawrectangle;
mask = createMask(r);
bw2 = activecontour(I2,mask,200,'edge');
figure
imshow(labeloverlay(I2,bw2));
hold on;
visboundaries(bw2,'Color','r');
the error .....
Error using labeloverlay
Expected A to be one of these types:
single, double, uint8, uint16, int16
Instead its type was logical.
Error in labeloverlay>parseInputs (line 131)
validateattributes(A,{'single', 'double', 'uint8', 'uint16', 'int16'},{'nonsparse','real','nonempty'},mfilename,'A');
Error in labeloverlay (line 88)
parsedInputs = parseInputs(varargin{:});
Error in Untitled (line 20)
imshow(labeloverlay(I2,bw2));

採用された回答

Walter Roberson
Walter Roberson 2021 年 12 月 9 日
im2bw() returns a logical matrix. You crop that logical matrix, which leaves it as a logical matrix. You then pass that to labeloverlay() but labeloverlay() does not permit logical matrices for its first position. You should im2double() before passing it into labeloverlay()
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 12 月 9 日
imshow(I2)
title('Cropped Image')
imshow(A)
title('Original Image')
r = drawrectangle;
mask = createMask(r);
You are doing the drawrectangle() over the original image, not over the cropped image. The coordinates you get will probably be outside the coordinates for the cropped image.
MOHAMED GILANI
MOHAMED GILANI 2021 年 12 月 9 日
OKK THANKS

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by