Understanding montage() command settings

15 visualizaciones (últimos 30 días)
Matt J
Matt J el 26 de Sept. de 2013
Editada: Jin Ren el 28 de Mzo. de 2024 a las 7:59
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
whereas in figure(2), I see
Any clear reason why? Possibly, I'm misunderstanding something about how MONTAGE works.
  1 comentario
Matt J
Matt J el 27 de Sept. de 2013
No thoughts, here? I only recently came across montage and it would be useful to get it working.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 1 de Oct. de 2013
Editada: Matt J el 1 de Oct. de 2013
I have been told by tech support that, when a colormap argument is fed to MONTAGE, the DisplayRange option is deliberately ignored. They will update the documentation to clarify this.
Furthermore, although I still don't see the logic of it, I have also been told that the following are equivalent,
>> figure(1), montage(X, 'DisplayRange',[1 100])
>> figure(2), montage(X, gray(100));
i.e., the number of colormap entries is used to determine the max value of X displayed...
  1 comentario
Jin Ren
Jin Ren el 28 de Mzo. de 2024 a las 7:58
Editada: Jin Ren el 28 de Mzo. de 2024 a las 7:59
See no point why MONTAGE acts like this, Colormap and DisplayRange apparently should be independent.

Iniciar sesión para comentar.

Más respuestas (1)

Jeff E
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
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))
Matt J
Matt J el 28 de Sept. de 2013
where the colormap is set, and then scaled.
No, I'm not getting what you mean by this. Once set, the colormap is a fixed thing. It doesn't get scaled. The image values are the thing that get scaled and then compared to the colormap. I also don't understand the implications of your example
figure(3); imagesc(X2, [0 255]);
or why we need to consider X2. All this means is simply that X2 will be scaled internally so that all values that used to lie between [0,255] will now lie between [0,1] before being compared by the renderer to the colormap. I obtain the exact same image when I do
figure(3); imagesc(X, 2*[0 255]);
As for montage, it seems clear from the additional examples below that DisplayRange is ignored. The following produces the desired image
X=double(X);
montage(X*256/max(X(:)),gray(256))
But all of the following produce exactly the same image with no change
>> montage(X*256/max(X(:)),gray(256),'DisplayRange',[0,.001])
>> montage(X*256/max(X(:)),gray(256),'DisplayRange',[1000,1001])
>> montage(X*256/max(X(:)),gray(256),'DisplayRange',[rand,rand+1])

Iniciar sesión para comentar.

Categorías

Más información sobre Red en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by