kaki_img=imread('box_dark.jpg');
figure(2)
imshow(kaki_img,'Border','tight','InitialMagnification','fit');
kaki_red=kaki_img(:,:,1);
figure(3)
imshow(kaki_red,'Border','tight','InitialMagnification','fit');
kaki_th=kaki_red>180;
figure(4)
imshow(kaki_th,'Border','tight','InitialMagnification','fit');
kaki_th=imfill(kaki_th,'holes');
figure(5)
imshow(kaki_th,'Border','tight','InitialMagnification','fit');
cc1=bwconncomp(kaki_th);
main1=regionprops(cc1,'Area');
A=[main1. Area];
[~,biggest]=max(A);
kaki_th(labelmatrix(cc1)~=biggest)=0;
figure(6)
imshow(kaki_th,'Border','tight','InitialMagnification','fit');
BW=imbinarize(kaki_th);
figure(7)
imshow(BW,'montage')
エラー: imbinarize
I は以下のいずれかのタイプが必要です:
uint8, uint16, uint32, int8, int16, int32,
single, double
実際の型は logical でした。
エラー: imbinarize>validateImage (line 262)
validateattributes(I,supportedClasses,supportedAttribs,mfilename,'I');
エラー: imbinarize>parseInputs (line 198)
validateImage(I);
エラー: imbinarize (line 134)
[I,isNumericThreshold,options] =
parseInputs(I,varargin{:});
エラー: sisaku (line 33)
BW=imbinarize(kaki_th);