save RGB image as a single layer/channel
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
AbioEngineer
el 3 de En. de 2021
Comentada: AbioEngineer
el 3 de En. de 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 comentarios
Respuesta aceptada
Image Analyst
el 3 de En. de 2021
Editada: Image Analyst
el 3 de En. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Denoising and Compression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!