How to count each pixel with new semantic image

1 visualizzazione (ultimi 30 giorni)
I now want to count each pixel for when an image goes through the network and produces semantic data. How do i do this? when the tutorial does count each pixel in the tutorial it does this for one image and uses PXDs.
To perform the semantic segmentation for a random image te following code is used:
I = read(imdsTest);
C = semanticseg(I, net);
B = labeloverlay(I,C,'Colormap',cmap,'Transparency',0.4);
imshow(B)
pixelLabelColorbar(cmap, classes);
How can i use this data to count the pixels in this outputted image for the labels?
The code used at the start to coun each pixel is:
labelDir = fullfile(outputFolder,'labels');
pxds = pixelLabelDatastore(labelDir,classes,labelIDs);

Risposte (1)

Varun Sai Alaparthi
Varun Sai Alaparthi il 15 Nov 2022
Hello Benjamin,
I understand that you are looking for a way to get the pixel count with respect to labels for output image but the output from which function wasn’t clearly mentioned.
However, If the output is from the semanticseg function following code can be used
c = semanticseg(img,net);
out= reshape (c,1,[]);
Summary(out)
This will provide you the pixel count
Sincerely
Varun

Community Treasure Hunt

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

Start Hunting!

Translated by