colormap option does not work with imshow in MATLAB 2017a

5 visualizaciones (últimos 30 días)
Vishwa Parekh
Vishwa Parekh el 27 de Mzo. de 2017
Comentada: QQ Tong el 31 de Oct. de 2017
colormap option does not work with imshow in MATLAB 2017a.

Respuesta aceptada

Andrew Gilman
Andrew Gilman el 23 de Jun. de 2017
It looks like imshow() now sets the axis colormap (it uses default if colormap is not specified). Axis colormap over-rides the figure colormap - this allows to have multiple axis with different colormaps.
colormap function sets figure's colormap by default when no handle is specified, but this is over-ridden by the axis colormap and you don't see any change.
To change the colormap you can use colormap(gca,jet), which will set colormap to the axis. Alternatively use image() instead of imshow(), which doesn't seem to set axis colormap and changing the figure colormap with the usual colormap jet has an effect on the image.

Más respuestas (1)

Jyotish Robin
Jyotish Robin el 30 de Mzo. de 2017
Hi!
Since you haven't provided much detail on how you are using 'imshow' and 'colormap' functions, I am writing a sample code to illustrate the issue and hopefully this matches with your usecase:
map = [0.83, 0.83, 0.83
0.7, 0.7, 0
0.1, 0.5, 0.8
0.2, 0.7, 0.6
1, 0, 0
];
figure;
subplot(1,2,1); imshow(peaks), title('Image 1');
colormap(map); colorbar
subplot(1,2,2); imshow(peaks), title('Image 2');
colormap(map); colorbar
The output figure is something like this:
If you read the documentation, it says that 'imshow' can be used in conjunction with 'subplot' to create figures with multiple images, even if the images have different colormaps. If a colormap is specified, 'imshow' uses the 'colormap' function to change the colormap of the axes containing the displayed image. In R2016a and prior releases, imshow changed the Colormap property of the figure containing the image.
Now if you rewrite the code as
map = [0.83, 0.83, 0.83
0.7, 0.7, 0
0.1, 0.5, 0.8
0.2, 0.7, 0.6
1, 0, 0
];
figure;
subplot(1,2,1); imshow(peaks, map), title('Image 1');
colorbar
subplot(1,2,2); imshow(peaks, map), title('Image 2');
colorbar
You get the following figure as output:
So, hopefully you could update the code as above to get the desired behaviour.
Hope this answer helps!
Regards,
Jyotish

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by