The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Color map and color bar of the overlaid index image on a gray scale background image?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 110
Registered: 6/2/11
Color map and color bar of the overlaid index image on a gray scale background image?
Posted: Dec 10, 2012 10:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi smart guys,

I use following example codes to overlay an index image on a background image (in the example below it is RGB but for my problem the background is a gray sacle image). Then my questions are:

1. How to display the colorbar on the side of the overlaid image? The colorbar should be the colorbar of the overlaid index image NOT the colorbar of the background image.

2. How to fix the color map range of the overlaid index image? I have several pairs of gray scale background + overlaid index image (using 'jet' color map). I need them to be shown in the same scale. I try to use set(iim2,'caxis', [0 1]); but the 'image' in Matlab hasn't got the property of 'caxis'.

Please help and thanks very much!

% Create the background
% This example uses a blend of colors from left to right, converted to a TrueColor image
% Use repmat to replicate the pattern in the matrix
% Use the "jet" colormap to specify the color space
bg = ind2rgb(repmat(1:64,64,1),jet(64));

% Create an image and its corresponding transparency data
% This example uses a random set of pixels to create a TrueColor image
im = rand(100,100,3);
% Make the image fade in from left to right by designing its alphadata
% Use repmat to replicate the pattern in the transparency fading
imAlphaData = repmat(0:1/size(im,2):1-1/size(im,2),size(im,1),1);

% Display the images created in subplots
hf = figure('units','normalized','position',[.2 .2 .6 .6]);
ax1 = subplot(2,3,1);
ibg = image(bg);
axis off
ax2 = subplot(2,3,4);
iim = image(im);
axis off
title('Image without transparency yet')

% Now set up axes that overlay the background with the image
% Notice how the image is resized from specifying the spatial
% coordinates to locate it in the axes.
ax3 = subplot(2,3,[2:3, 5:6]);
ibg2 = image(bg);
axis off
hold on
% Overlay the image, and set the transparency previously calculated
iim2 = image(im,'XData',[30 50],'YData',[10 30]);
title(sprintf('Using transparency while overlaying images:\nresult is multiple image objects.'))

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.