plaingeekspeak
plaingeekspeak

Reputation: 90

What does the index refer to when selecting a pixel on an image in Matlab?

When looking at a single pixel of an image in Matlab, what does this index refer to? X/Y refer to the coordinates of the pixel, and RGB refers to the color, but any ideas on what the index is?

To clarify, when I am viewing a figure in Matlab and use the data cursor to select a point, the three lines shown are:

X: ### Y: ###

Index: ###

RGB: ###, ###, ###

I am trying to "average" several dicom images together, and it appears that the numbers that are added and being manipulated is this index value, but I'm not sure what it refers to.

For example, here is an image that I might be reading:

%loads MRI
I = dicomread(filename); %enters MRI

%displays MRI
figure
imshow(I)
imcontrast

Then, using the toolbar on the Matlab figure, I used the data cursor to look at a pixel.

Thanks!

Upvotes: 2

Views: 971

Answers (1)

rayryeng
rayryeng

Reputation: 104555

If you want to talk about "index", we need to go into what are known as indexed images. Take for example the mandrill data set that you can load into MATLAB via:

>> load mandrill

You see that there is a colour map called map and an indexed image called X. The colour map is a N x 3 matrix where each row gives you a unique RGB tuple that describes a particular colour. The first column is the proportion of red, the next column is the proportion of green and the last column is the proportion of blue that describes the colour in that row. All colours are between [0,1] which make sense as we're describing proportions.

When we take a look at indexed images, each location in this image gives you the location in the colour map that you would need to sample from in order to represent what colour this pixel is at this point. A great pictorial representation can be shown here:

Source: MathWorks

As you can see, the indexed image gives you the right row you need to sample from in the colour map so that you can fill in the corresponding location with the right colour. As such, for the circled pixel in the indexed image, the index is 5, which means that we need to get the fifth row of the colour map and that's the colour that we would need to paint onto the screen.


For the case of grayscale images, the index is simply the intensity. If you want to look at it blindly, the index is simply the value seen at the image itself, whether it be an indexed image or a grayscale image. However, depending on the context, the index means to either sample from a colour map, or just look at the intensity of the image itself.

Upvotes: 4

Related Questions