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

13 visualizzazioni (ultimi 30 giorni)
How can I calculate the IoU between the original image and the predicted one as shown in attached image?

Risposte (1)

Shreeya
Shreeya il 28 Set 2023
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 Commenti
yasmin ismail
yasmin ismail il 3 Ott 2023
@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 il 8 Ott 2023
@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??

Accedi per commentare.

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by