Does imshow have side effects in Matlab? And how can I resolve them?

51 views Asked by At

I have two axes let's say A1 and A2, and on A2 I have an image that displays with imshow, on A1 I display something entirely different with imagesc, and it produces a different result color-wise when A2 is used. Here is some example code, likely the shortest example:

a = zeros(1); 
[b,bmap] = imread('F.bmp');
c = figure();
d = axes('Parent',c,'Position',[0,0,.5,1]);
e = axes('Parent',c,'Position',[.5,0,.5,1]);


axes(d);
imagesc(a);
pause();
axes(e);
imshow(b,bmap);
pause();
cla(d);
axes(d);
imagesc(a);
figure();
axes();
imagesc(a);

The image a displays differently after b is shown, but when displayed in a different figure it displays normally. How can I fix this?

1

There are 1 answers

0
Hovestar On BEST ANSWER

After digging in I think it is because providing the map, bmap to imshow causes the figure.Colormap value to change, so this can be fixed by typing colormap default after an imshow command.