Reputation: 2256
I need to take a very large matrix that is generated by using the function imread()
. This turns an image (mine is a jpg file; 691x763) into a matrix.
I need to divide each element in the matrix by 255 and show each element with at least 3 decimal places.
What I've tried:
output_precision(4)
but it didn't work for the elements inside the matrix.
format long e
but the values inside the matrix were still unaffected.
Upvotes: 0
Views: 50
Reputation: 8091
You should use im2double
http://octave.sourceforge.net/image/function/im2double.html which does the scaling to 0..1 for you independently of the input format which might be uint, uint16, int16 and so on.
Upvotes: 2
Reputation: 2303
I'm guessing imread()
gave you a matrix of uint8
. Try this instead:
I = imread('image.jpg'); %// your image
A = double(I)/255; %//convert matrix to double before dividing it by 255
Upvotes: 1