Intensity image of two variables

1 view (last 30 days)
Sunil
Sunil on 23 May 2014
Answered: Geoff Hayes on 23 May 2014
Hi, i have two variables: I1 is the indices of a matrix and I2 is the no. of times it was selected. For ex: I1=[256 412 234 567 9 89 87], I2=[2 4 2 3 5 6 9]. I want to plot this as an image (something like an intensity map) in which I1 is on y-axis and I2 on x-axis. Can someone help me with this?

Accepted Answer

Geoff Hayes
Geoff Hayes on 23 May 2014
Hi Sunil - it sounds like you want to create some sort of bar chart (given your labels for the x- and y-axes) but as an image. Since your tags to this question are image and digital image processing why not create an intensity map with the map being the same size as the image and you use colour to indicate how many times a index has been selected? I know you said "something like an intensity map" - was there a reason why you don't want to use one? If your original matrix is large, then your x-axis (the indices) may not easily show (because too long) the data in a readable/understandable manner. Using the (row,column) "coordinates" of the selected value in the image rather than its index may be more desirable.
Suppose your matrix (that you obtained the indices from) is mxn. Then:
intensities = zeros(m,n); % create the matrix of all zeros
intensities(I1) = I2; % assign the selection count for the indices
imagesc(intensities); % display the intensities as an image
colorbar % display the colorbar to the right of the image
So the above code will display an image the same size as your matrix (original image) with the (default) colorbar indicating in red those indices that are selected the most.
An alternative, which can be manipulated/rotated to return something more like what you asked for, is to use the surf command. Again, suppose that your matrix (that you obtained the indices from) is mxn. Then:
intensities = zeros(m,n); % create the matrix of all zeros
intensities(I1) = I2; % assign the selection count for the indices
surf(intensities); % display the intensities as a 3d surface
colorbar % display the colorbar to the right of the surface
And you can rotate the image as you see fit. Hope that this helps!

More Answers (0)

Community Treasure Hunt

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

Start Hunting!