Save several images with the same colormap
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Here is my problem:
I have N matrixes generated on MatLab (N could be 1, 100, 1000, etc). How I generated them and why is not important.
I want to save those matrixes as images, with names in a sequence.
So at first I showed them to me using this code:
figure;
image(rho); #rho is the name of the matrix with all variables
colormap(hsv(ceil((rhomax-rhomin))));
cbh = colorbar('location', 'SouthOutside');
set(cbh, 'Units', 'normal', 'Xtick',0:0.5:ceil(rhomax));
text(2.5, -1, 'Densidade(g/cm³)', 'Parent', cbh);
And I got this:
I then tried to save those images using this part of a code.
r = sprintf('rho%04d.tif',d);
imwrite(rho,hsv((ceil(rhomax-rhomin))),r,'tif')
I use 'd' so I can later save another image with a number inside a sequence, for example, rho0001, rho0002, and so on.
And I got this:
As you can probably see, they are different, but they shouldn't be, because I'm using the same map - or, at least, I think I am.
So I think there is probably three possible answers to this problem:
1 - save the figures, with colorbars.
2 - find a colorbar to the second one
3 - solve this "puzzle" and have them be the same in the end.
Does anyone know how to do any of those 3? I don't know how to save those images with colorbars automatically. I also don't know how to find a colorbar for the 2nd image. And I'm still trying to figure out why those two images are different.
0 commentaires
Réponses (1)
Image Analyst
le 2 Juin 2014
if rho changes, hsv((ceil(rhomax-rhomin))) (your colormap) will change. Does that explain it?
To save the figures you can use export_fig() or getframe().
5 commentaires
Voir également
Catégories
En savoir plus sur Orange dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!