How can I use same color range on subimages?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ludmila Nemsilajova
le 5 Mar 2015
Commenté : Ludmila Nemsilajova
le 7 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
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.
Réponse acceptée
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
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));
Plus de réponses (1)
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.
Voir également
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!