converting binary image to rgb image back after enhancing to show the enhancement

1 visualizzazione (ultimi 30 giorni)
Hi, I converted my rgb tif image to binary image to apply morphological filters for enhancing .Now i want to convert the final binary image to rgb iamge to show the enhanced result.How can i do it? please help me

Risposte (2)

Image Analyst
Image Analyst il 18 Apr 2013
You don't need to. There is nothing whatsoever to be gained by converting a binary image (of class "logical" and values of true/false or 1/0) to an RGB image. If you really wanted to for some reason, you could create a 3D RGB image like this:
rgbImage = 255 * cat(3, binaryImage, binaryImage, binaryImage);
though it will look pure black (0) and pure white (255) with no gray scale pixels and no "color" pixels. Again, this is not necessary to view the binary image so that you can see the "enhanced result" - you can see the image just fine passing it to imshow().

Sean de Wolski
Sean de Wolski il 18 Apr 2013
Modificato: Sean de Wolski il 18 Apr 2013
You could use label2rgb() to do this.
doc label2rgb
Then you can pick your two colors. Or you could just show it with a colormap:
imshow(rand(100)>0.6,jet(2))
This is probably a better solution since, like IA said, there is nothing to be gained by converting to RGB other than for visualization sake.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by