From: ClaudioV on
Hi
here a question maybe trivial
How do you display in maltab a colored image with some parts of it in
grayscale (e.g. suppose you have an image of a city in color and you
want one specific building to appear in a grayscale within the image)
Thanks for any help
-Claudio
From: Walter Roberson on
ClaudioV wrote:

> How do you display in maltab a colored image with some parts of it in
> grayscale (e.g. suppose you have an image of a city in color and you
> want one specific building to appear in a grayscale within the image)

Create a copy of the image as class double() scaled to [0, 1]; if the
image is already true color double then just copy it; if it is a
different data type but still true color then double() the data and
divide by double(intmax(class(OriginalImage))); if it is a pseudo-color
image then index2rgb() to create the true color version of the image.

Once you have the working copy in double scaled to [0, 1], extract the
pixels you want to be in grayscale, and pass them through rgb2gray(),
and write them back in to the working copy in the appropriate positions.
If you are lucky then you are extracting a rectangular region, but if
not, if you are using an ROI, you will probably want to use sub2ind to
allow you to vectorize the extraction and replacement.