How can I invert the colors of an image without changing the values ​​in the colorbar in Matlab

I draw a confusion matrix as follows with a colorbar in it:

enter image description here

What I would like to do now is to keep everything exactly the same, but invert the colors. I tried the following code (which I read from another post in SOF):

myimage = sum(255 - myimage, 3); 

And it gives me:

enter image description here

And this is exactly what I want, except that the values ​​in the color bar have changed ... How can I do the same without changing the values ​​in the color bar?

Thanks for any help =)

+4
source share
1 answer

Why don't you just invert the color code by flipping up and down ( flipud )? For instance:

 cmap=flipud(colormap(gray)); colormap(cmap); 

or in a more compact way:

 imagesc(your_image); colormap(flipud(gray)) 
+9
source

Source: https://habr.com/ru/post/1493374/


All Articles