How to add a “color panel” and set a “click” on a color image superimposed on the image at a gray level?

I am trying to overlay a color image on a gray level image. However, when I try to build a "colorbar" and set the "click". Matlab always creates a color bar to match the gray level image.

However, I want to get a color panel for the overlay color image. Any suggestions would be appreciated. Thank you very much.

%% Example codes: greyImage = imread('AT3_1m4_08.tif'); colorImage = imread('hestain.png'); figure, greyImagePlot = image(greyImage); colormap(gray); hold on; overlayImage = imagesc(colorImage, ... 'CDataMapping', 'scaled', 'HitTest', 'off'); alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2)); set(overlayImage, 'AlphaData', alF); colorbar; % This will show a grey scale colorbar not the colour one I want set('CLim', [0 100]); % Also, the colormap limit here is not working axis off axis image 
+1
source share
1 answer

Here you can find the link for single digits / several color folders http://www.mathworks.fr/support/solutions/en/data/1-GNRWEH/index.html

Using images, in particular, you can use the function "subimage".

I also use the functions "FreezeColor" and "cbfreeze" from "matlabcentral" when a homemade solution is too complicated. http://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors http://www.mathworks.com/matlabcentral/fileexchange/24371

A simple and lazy solution for saving a color panel on several graphs within the same axis: first draw a color image and its color panel, freeze the color panel, then draw the image at a gray level (without transparency) and finally draw the color image again (transparency) .

Here is a snippet of code.

 figure; %first step: RGB image and colorbar overlayImage = imagesc(colorImage, 'CDataMapping', 'scaled', 'HitTest', 'off'); alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2)); set(overlayImage, 'AlphaData', alF); colorbar; set(gca, 'CLim', [0 100]); cbfreeze; %from 'COLORMAP and COLORBAR utilities' in Matlab Central %second step: gray image (no transparency) greyImagePlot = image(greyImage); colormap(gray); hold on; %third step: plot colour image overlayImage = imagesc(colorImage, ... 'CDataMapping', 'scaled', 'HitTest', 'off'); alF = 0.5.*ones(size(colorImage, 1), size(colorImage, 2)); set(overlayImage, 'AlphaData', alF); axis off axis image 
+3
source

Source: https://habr.com/ru/post/950005/


All Articles