Convert uint8 image to doubles
3 views (last 30 days)
Show older comments
Hello,
I'm trying to convert a png image from the web to a single 2d array of doubles, scaled from 0 to 1.
im2double works. But the problem is the image is actually 3 2d arrays. The first corresponds to red intensities, second one to green intensities, and third one is blue intensities (this seems to be a common format). im2double converts each of the three 2d arrays, but I need to combine them into a single 2d array for black/white intensity.
Is there a function for this? Any help?
0 Comments
Answers (1)
Walter Roberson
on 23 Aug 2013
im2double() applied to the 3D ("truecolor") array would convert the entire array.
If the original image is grayscale that has been represented as RGB, then the three color planes would be equal to each other. You would not need to convert each of the planes individually to get out a grayscale image represented in RGB
repmat( im2double(PNGImage(:,:,1)), 1, 1, 3); %convert one plane, clone that
If for some reason you do have three separate arrays, say R, G, B, then
cat(3, im2double(R), im2double(G), im2double(B))
or equivalently
im2double( cat(3, R, G, B))
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!