필터 지우기
필터 지우기

why do i got error with active countor edge ?

조회 수: 2 (최근 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개)

Community Treasure Hunt

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

Start Hunting!

Translated by