save RGB image as a single layer/channel
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
AbioEngineer
il 3 Gen 2021
Commentato: AbioEngineer
il 3 Gen 2021
I have an RGB image which is an n x n x 3 image, corresponding to the Red Green and Blue layers/channels respectively.
Using imshow(rgbimage) I can see the image I want to see, but when I use imwrite(im2uint16('pathtofile.tiff')) to save it as a tiff file, when I open it in ImageJ it displays the channels separately. I have to go into image>RGB color to "merge" the channels.
How can I save it from MATLAB directly as a 2D color tiff image? Is it as simple as just averaging each r,g,b element?
0 Commenti
Risposta accettata
Image Analyst
il 3 Gen 2021
Modificato: Image Analyst
il 3 Gen 2021
You need to pass an image variable to im2uint16, not a filename string. If the array is uint16 it will leave it alone. If the image is uint8 in the range 0 to 255, it will multiply the values by 257 (yes, 257, not 256 - just try it).
This works fine:
rgbImage = imread('peppers.png');
imshow(rgbImage);
image16 = im2uint16(rgbImage);
imwrite(image16, 'delete me.tif');
It opens in ImageJ as an RGB image though it does have a scrollbar for each color channel for some reason. Not sure why - might be just some kind of ImageJ quirk.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!