Save several images with the same colormap
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Image Analyst
2014-6-2
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().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!