Question about multiple imagesc on one axes, colorbar handling

8 views (last 30 days)
Brian
Brian on 6 May 2015
Answered: Image Analyst on 6 May 2015
Hello, thanks for reading this.
I've been stewing over this for a while, and I've been partially successful with this. What I want to do is create a single axes plot with two imagesc plots, with colorbars for each imagesc. What I can do at the moment is plot two fused imagesc datasets as one dataset, I can plot two imagesc and hold on, and I can use indexing on the NaN values to fill in one image into another (my datasets consist of a torso with a NaN cavity for lungs, and another for the lungs). I plot them both on one axes.
Note I want to plot these separately because the torso and lungs have apple and orange datasets. The only consistent information is the x,y,z spatial location of the pixels.
So like I said earlier, I can overlay the two images pretty well on one axes. My problem comes from being unable to make two colorbars for the two fused imagesc.
Is it possible to make colorbar data for the imagesc using the spatial orientation of the pixels, plus the cdata? I've tried looking at some of the demos out there, but the way I create my fused image makes multiple colorbars difficult.
Thanks for any advice you can give.

Accepted Answer

Walter Roberson
Walter Roberson on 6 May 2015
Have you considered using the file contribution freezeColors ?
That is, there are methods to transform relative-scaled data such as input to imagesc() into absolute data.
See also the Colormap / Colorbar Utilities file contribution
  1 Comment
Brian
Brian on 6 May 2015
Thanks, will take a look. This seems the close, probably the closest I'll get, I'll have to be creative with it though.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 6 May 2015
What I would do is to stitch each indexed/grayscale image with a gray ramp on the right. (I assume you know how to make a ramp with linspace() and repmat() - let me know if you don't). Then do it for the second image. Then convert those two images to an rgb image with ind2rgb().
image1 = [image1, verticalRamp];
colormap1 = jet(256); % Whatever colormap you want.
rgb1 = ind2rgb(image1, colormap1);
image2 = [image2, verticalRamp];
colormap2 = hsv(256); % Whatever colormap you want.
rgb2 = ind2rgb(image2, colormap2);
Then stitch them together
rgbPair = [rgb1, rgb2];
imshow(rgbPair);
If you want intensity labels along the ramp, then use text().

Community Treasure Hunt

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

Start Hunting!

Translated by