How to Plot precision recall curve for semantic segmenttaion

4 次查看(过去 30 天)
I have done training and testing for semantic segmentation. I want to make a graph of my precision recall. I have got precision and recall values when validating images. but i don't know how to plot percurve charts. The following is the code that I made
pic = 8;
I = readimage(imdsTest, pic); %ib
Ib = readimage(pxdsTest,pic);
BC = labeloverlay(I, Ib,'Colormap',cmap,'Transparency',0.5);
C = semanticseg(I, net);
B = labeloverlay(I,C,'Colormap',cmap,'Transparency',0.5);%cb
imshowpair (B, BC,'montage')
pixelLabelColorbar(cmap, classes)
title ('prediction vs groundtruth')
expectedResult = readimage(pxdsTest,pic);
actual = uint8(C);
expected = uint8(expectedResult);
imshowpair(actual,expected)
iou = bfscore(C,expectedResult);
[recall,precision,prediction]=bfscore(C,expectedResult)
table(classes',recall ,precision, iou)
the results of this program are as follows
ans =
Var1 recall precision iou
____________ _______ _________ _______
"crack" 0.34446 0.25696 0.34446
"background" 0.53501 0.60656 0.53501
to be able to make precision recall plots. What should I do? Please help me

回答(1 个)

Chinmay Budhiraja
Chinmay Budhiraja 2020-6-18
Hi,
According to my understanding, you want to study the precision recall curve for a task. We use ROC curve (Receiver Operating Characteristic Curve) for the same. Consider the following example:
load simplecluster_dataset
net = patternnet(20);
net = train(net,simpleclusterInputs,simpleclusterTargets);
simpleclusterOutputs = sim(net,simpleclusterInputs);
plotroc(simpleclusterTargets,simpleclusterOutputs)
In semantic segmentation, generally a multi-dimensional image is converted into a vector first by flattening (you can use reshape for the same) the matrix and then roc is plotted. You can tweak the above sample according to your use case. Please refer to plotroc for more information.

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by