How can I calculate the IoU between the original image and the predicted one as shown in attached image?

15 次查看(过去 30 天)
How can I calculate the IoU between the original image and the predicted one as shown in attached image?

回答(1 个)

Shreeya
Shreeya 2023-9-28
I understand that you want to calculate the IoU score between the original and predicted images using MATLAB. You can use the "evaluatesemanticsegmentation" function for this purpose. The input argument provided to the function are "dsResults" and "dsTruth" which refer to the predicted and ground truth images respectively. The output is a semantic segmentaion metrics object with GlobalAccuracy, MeanAccuracy, MeanIoU, and WeightedIoU as the default metrics.
You can refer to the documentaion linked below for more details: https://www.mathworks.com/help/vision/ref/evaluatesemanticsegmentation.html#d126e248885
Hope this helps!
  3 个评论
yasmin ismail
yasmin ismail 2023-10-3
@Shreeya how can I apply semantic segemnetation or any method by matlab to calculate the IoU bewtwwen the attached groundTruth(crack) ande the attacehed nodel outPut?
yasmin ismail
yasmin ismail 2023-10-8
@Shreeya I created an image truth and I tried to use evaluatesemanticsegmentation function as shown in
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);
metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTruth);
metrics
metrics.ClassMetrics
Then 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 already hve two files testImages and testLabels and each will contain 100 or more of groundTruth and testImages and all shoud enter semantic segemnation not only the attached images ,
How can I fix it to calculate IoU??

请先登录,再进行评论。

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by