why do i got error with active countor edge ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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));
댓글 수: 0
채택된 답변
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
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!