Converting Grayscale image to RGB
2 views (last 30 days)
Show older comments
Bintang Pamungkas
on 29 Jul 2013
Commented: Nagwa megahed
on 26 Oct 2021
Hi, I'm trying to find a simple way to convert a grayscale image (which initially was in RGB format) to RGB.
I'm designing a circuit in simulink which requires me to convert the RGB image to grayscale for processing, but then I want the output to be in RGB format rather than grayscale.
Is there any possible way to do this?
Thanks in advanced.
0 Comments
Accepted Answer
Walter Roberson
on 29 Jul 2013
In MATLAB itself, the way to do it would be
cat(3, GrayScaleImage, GrayScaleImage, GrayScaleImage)
or (more obscurely but correct and efficient)
GrayScaleImage(:,:,[1 1 1])
That is, take three copies of the grayscale image and put them together along the Z axis.
I do not know the Simulink methods to achieve the same thing.
You need to consider, though, whether what you want is the grayscale image in the form of an RGB image, which would give you an RGB image that consisted entirely of grays. Or do you instead need to use the results of processing the grayscale image to select or modify portions of the original RGB image, producing a full-color RGB output? Such as, for example, the RGB image with edges "drawn" on it.
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!