Error using images.int​ernal.imag​eDisplayVa​lidatePara​ms>validat​eCData (line 122) If input is logical (binary), it must be two-dimensional.

a=imread('c1.jpg');
imshow(a)
cd=double(a);
imshow(cd)
imshow(cd/255)
cd1=im2double(a);
figure, imshow(cd1)
c= a>120;
imshow(c)
impixelinfo
OUTPUT
Error using images.internal.imageDisplayValidateParams>validateCData (line 122)
If input is logical (binary), it must be two-dimensional.
Error in images.internal.imageDisplayValidateParams (line 30)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 79)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in img (line 9)
imshow(c)

답변 (2개)

Nearly all jpg are rgb. You are not converting to grayscale before doing your test against 120
imshow(cd/255);

댓글 수: 1

They already have that in their code, and the line is not a problem for them. Their problem was with
c= a>120;
imshow(c)
and imshow() is complaining that logical values must be 2 dimensional.
Th is likely caused by a being 3 dimensional instead of 2 dimensional. The input file is JPG. and the overwhelming majority of JPG files are RGB images instead of grayscale images. The initial specification for JPG did not permit grayscale images, so for maximum compatibility with old readers, most JPG writing software converts grayscale images to the equivalent RGB images and writes those.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

질문:

2020년 2월 8일

댓글:

2021년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by