How can I use same color range on subimages?

14 vues (au cours des 30 derniers jours)
Ludmila Nemsilajova
Ludmila Nemsilajova le 5 Mar 2015
Hi, I want, that my all subimages have the same colour range. I´m using caxis command but it doesn´t work. Can you help me? I'm lost. (sorry for my english)
bottom = min(min(min(mmin1,mmin2),mmin3),mmin4);
top = max(max(max(mmax1,mmax2),mmax3),mmax4);
subplot(3,2,1+2)
subimage(imresize(imag,20),colormap(jet));
axis off
caxis manual
caxis([bottom top]);
colorbar;
subplot(3,2,2+2)
subimage(imresize(imag,20),colormap(jet)),
axis off
caxis manual
caxis([bottom,top]);
colorbar;
  2 commentaires
Adam
Adam le 5 Mar 2015
That seems like generally what you should be doing though I always use explicit axes handles for any plotting-related functions to ensure it is being applied to the correct axes.
I can't run your code though as I don't have all the variables defined that you have.
Ludmila Nemsilajova
Ludmila Nemsilajova le 6 Mar 2015
In my code, mmin1-mmin4 are minims of matrix (i have 4 matrix, M1(:,:,id_1)...M4(:,:,id_4) size is 10x16 and values in range -2:2 (e.g. -0.03) and first imag is
I = mat2gray(M1(:,:,id_m1));
[imag,map] = gray2ind(I);
where, M1(:,:,id_m1) is one of matrix, second imag ist same but for second matrix.
And I want to display one colormap on all of these imag, i want display same values of matrix in same colour.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 5 Mar 2015
Not sure what you're asking about. If you just display a bunch of grayscale images and then apply a colormap, it has all images use the same colormap so that the same gray scale intensities are mapped to the same colors. In R2014b you can change that and have different colormaps with different axes. What version do you have and why aren't all your images having the same color map now? They should have, unless you're using R2014b and specifically went to the trouble to make then not use the same colormaps.
  5 commentaires
Image Analyst
Image Analyst le 6 Mar 2015
You're doing all kinds of stuff you should not be doing. Why do you think you need to call mat2gray and gray2ind()? You should not. Try this:
M = rand([10,16,4],'single');
bottom = min(M(:))
top = max(M(:))
subplot(2, 2,1)
imshow(imresize(M(:,:,1),20));
colorbar;
subplot(2, 2,2)
imshow(imresize(M(:,:,2),20));
colorbar;
subplot(2, 2,3)
imshow(imresize(M(:,:,3),20));
colorbar;
subplot(2, 2,4)
imshow(imresize(M(:,:,4),20));
colorbar;
colormap(jet(256));
Ludmila Nemsilajova
Ludmila Nemsilajova le 7 Mar 2015
Thank you so much! I just need add caxis and it works.
imshow(imresize(imag,20));
caxis([bottom top]);
colorbar;
I call mat2gray and gray2ind becouse i tried a lot of things before and I don't delete it...I'm still beginer in matlab so really thank you!

Connectez-vous pour commenter.

Plus de réponses (1)

Adam
Adam le 6 Mar 2015
Ok, now that I have looked at the help page for subimage as I have never used it, it works by converting your image to true colour for display by applying the colourmap you give. That means it will be unaffected by changes to the 'CLim' property (e.g. via caxis).
If you wish to change the colour scaling you will have to do it on the image (or the colourmap) before you call subimage because once it converts to true RGB the colourmap becomes irrelevant.
It is confusing that Matlab allows you to put a colourbar on the screen even for images that are unaffected by it, but that is just the way it works.
  1 commentaire
Ludmila Nemsilajova
Ludmila Nemsilajova le 7 Mar 2015
Finally i don't use subimage but imshow after call subplot...like this
imag = M1(:,:,id_m1);
subplot(3,2,1+2)
imshow(imresize(imag,20));
caxis([bottom top]);
colorbar;
colormpat(jet(256));
and it finally work, thank you for your help.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by