How to save labeled superpixels and visualize them in .pgm format in Matlab?

I'm working with the ERS (Entropy Rate Superpixels) algorithm in Matlab for segmenting images into superpixels. I'm considering forming 200 superpixels. When saving the file in .pgm format, with the commands

imwrite(labels, 'labels.pgm')

and

imwrite(labels, 'labels.pgm', 'MaxValue', 199)

I get a view from the entire range 0 to 255 as shown below:

ERS Label in .pgm format for the entire range

When using the command

imshow(labels, [0 199])

I get a better view of all the superpixels as shown below:

ERS Label visualization for the range between 0 and 199

Questions: How do I save image 2 in .pgm format? Are there practical differences if saving in a limit range or the whole range (I don't think so)? Regarding the creation of .pgm files in Matlab, is there any specific issue that I should consider for correct visualization and extraction of characteristics such as (color and texture) in other programs?

Upvotes: 1

Views: 82

Answers (0)

Related Questions