Understanding montage() command settings
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matt J
el 26 de Sept. de 2013
I feel like the following code should display virtually identical looking images in figure(1) and figure(2)
load mrislice;
figure(1); imagesc(X); axis image off, colormap(gray(256)),
figure(2); montage(X,gray(256),'DisplayRange',[]),
It does not, however. In figure(1), I see the expected result
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150101/image.jpeg)
whereas in figure(2), I see
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150103/image.jpeg)
Any clear reason why? Possibly, I'm misunderstanding something about how MONTAGE works.
Más respuestas (1)
Jeff E
el 27 de Sept. de 2013
From the imagesc documentation, emphasis mine:
The imagesc function scales image data to the full range of the *current* colormap...
Your first image is scaled to the colormap immediately when you call imagesc. Try the following:
X2 = X ./ 2; %halve the image intensity
figure(1); imagesc(X); axis image off, colormap(gray(256))
figure(2); imagesc(X2); axis image off, colormap(gray(256))
figure(3); imagesc(X2, [0 255]); axis image off, colormap(gray)
The first two images look the same, while the third shows the expected decrease in intensity.
3 comentarios
Jeff E
el 27 de Sept. de 2013
Because montage is the functional equivalent of figure 3, where the colormap is set, and then scaled. The way you're calling imagesc, the image is scaled and then the colormap is set.
figure(4); montage(X, gray(256), 'DisplayRange', []);
figure(5); montage(X2, gray(256), 'DisplayRange', []);
Note that figure 4 and 5 using montage look different, but figure 1 and 2 using imagesc look the same.
If you want montage to behave similarly to imagesc, then I think you want this:
figure(6); montage(X2, 'DisplayRange', []); axis image off, colormap(gray(256))
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!