views:

56

answers:

1

Or say does 1 denotes white for an RGB image?

I have this question because of this answer:

http://stackoverflow.com/questions/2619668/how-to-convert-a-grayscale-matrix-to-an-rgb-matrix-in-matlab/2619714#2619714

Can someone clarify it?

+1  A: 

Image data in MATLAB can be stored as different data types. The type of image as well as the data type it is stored as will determine what constitutes the color "white":

  • A grayscale image matrix (which has one data value per pixel) can be any one of the following data types: uint8, uint16, int16, single, or double. From the documentation:

    For a matrix of class single or double, using the default grayscale colormap, the intensity 0 represents black and the intensity 1 represents white. For a matrix of type uint8, uint16, or int16, the intensity intmin(class(I)) represents black and the intensity intmax(class(I)) represents white.

  • An RGB image matrix (which has three data values per pixel: red, green, and blue) can be any one of the following data types: uint8, uint16, single, or double. From the documentation:

    In a truecolor array of class single or double, each color component is a value between 0 and 1. A pixel whose color components are (0,0,0) is displayed as black, and a pixel whose color components are (1,1,1) is displayed as white.

gnovice
So in my previous post,`rgbImage = grayImage / 255;` is the right solution to convert a grayscale image into an RGB one of type double?
@user198729: Not quite. I'll add an answer to that other question.
gnovice
@gnovice ,great!
So a `double` matrix with elements greater than `1` actually means nothing?If so,why `double(grayImage)` doesn't scale the result by `255` implicitly/automatically,but require us to do it explicitly by `double(grayImage)./255`?
@user198729: A `double` matrix *can* have values greater than 1, but if that matrix is supposed to be an *image data matrix* then most if not all of the image processing functions will throw an error/warning when you pass the image data to them (since they expect image data matrices of type `double` to have values between 0 and 1). The conversion to double doesn't automatically scale by 255 because not all things that you want to convert to double are going to be image data matrices, so you have to scale it yourself.
gnovice
You mentioned `truecolor`,is there a `falsecolor`?
@user198729: Conceptually, yes there is such a thing as "False-color": http://en.wikipedia.org/wiki/False-color. It simply refers to an image whose colors don't match what you would expect the normal colors to be (which is done to enhance certain details or to display things that have no normal color, like non-visible spectra). With respect to the MATLAB documentation, the term "Truecolor" is synonymous with "RGB image" and refers to an image in which each pixel is specified by three values. In this respect, there is no consideration of whether the colors in the image are correct (or "true").
gnovice
+1 for all the work!
Jonas