How to solve the error: Expected input number 2, B, to be one of these types: logical, double, categorical Instead its type was uint8?

조회 수: 28 (최근 30일)
I used jaccard method as following:
A = imread('R7001-60.png');
I = im2gray(A);
figure
imshow(I)
title('OutPut Image')
mask = false(size(I));
mask(25:end-25,25:end-25) = true;
BW = activecontour(I, mask, 300);
BW_groundTruth = imread('gT7001_60.png');
similarity = jaccard(BW, BW_groundTruth);
and I got the following error:
Error using jaccard
Expected input number 2, B, to be one of these types:
logical, double, categorical
Instead its type was uint8.
Error in
jaccard>@(x,name,pos)validateattributes(x,{'logical','double','categorical'},{'real','nonempty','nonsparse'},mfilename,name,pos)
(line 118)
validateInput = @(x,name,pos) validateattributes(x, ...
Error in jaccard (line 124)
validateInput(B,'B',2);
Error in Gtruth3 (line 37)
similarity = jaccard(BW, BW_groundTruth);
can anyone help me to fix it?

채택된 답변

Matt J
Matt J 2023년 10월 6일
BW_groundTruth = logical(imread('gT7001_60.png'));
  댓글 수: 4
yasmin ismail
yasmin ismail 2023년 10월 6일
@Matt J another question , I tried to use evaluatesemanticsegmentation function as follow:
destinationTestLabels = "D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\crack\testLabels";
destinationTestImages = "D:\Matlab pics\matlab practices21\Phd analysis\trial meyhods\GroundTruth\crack\testImages";
testImagesDir = fullfile(destinationTestImages,'testImages');
testLabelsDir = fullfile(destinationTestLabels,'testLabels');
pixelLabelID = [1 0];
classNames = ["crack" "background"];
imds = imageDatastore(destinationTestImages);
pxdstest11 = pixelLabelDatastore(destinationTestLabels,classNames,pixelLabelID,"FileExtensions",".png");
data = load('triangleSegmentationNetwork');
net = data.net
pxdsResults = semanticseg(imds,net,"WriteLocation",tempdir);
I got the following error:
Error using SeriesNetwork/activations (line 817)
The spatial dimension sizes [313 316 3] of the input images to layer 'imageinput' must be greater than
or equal to the corresponding minimum input dimension sizes of the layer [32 32 1].
Error in semanticseg>iPredictDAGSeriesNetwork (line 609)
allScores = activations(net, X, layerName, ...
Error in semanticseg>iClassifyImagePixels (line 556)
allScores = iPredictDAGSeriesNetwork(X, net, params);
Error in semanticseg>iProcessImageDatastoreSerially (line 938)
L = iClassifyImagePixels(X{i}, net, params);
Error in semanticseg (line 265)
filenames = iProcessImageDatastoreSerially(ds, net, params);
Error in Gtruth3 (line 11)
pxdsResults = semanticseg(imds,net,"WriteLocation",tempdir);
I followed the same steps mentioned in:
www.mathworks.com/help/vision/ref/evaluatesemanticsegmentation.html
The files mentioned has the same previouse two attached images, can You help me to fix this erro to calculate IoU?
Matt J
Matt J 2023년 10월 6일
@Matt J another question ,
Please post it in its own thread, and Accept-click the answer to the one you posted here.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by