I have a set of values between 0 and 1. After i put these values between 0 and 255 I want to save them as a grayscale image in pgm format. The problem is the fact that after I save it as an image the values i get when i read the image are different from the previous matrix with values between 0 and 255.
Here is an simple example:
>> a=[0.5,1,0.3]
a =
0.5000 1.0000 0.3000
>> b=single(floor(255 * a))
%these are the values I want in the image
b =
127 255 76
imwrite(b, 'test.pgm');
% i don't want these values!!!
c=imread('test.pgm')
c =
255 255 255
what's happening? why matlab does not save my values? is this a conversion issue?