Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I invert the colors of a picture, without changing the values in colorbar in Matlab

I'm plotting a confusion matrix as the following with colorbar in it:

enter image description here

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

myimage = sum(255 - myimage, 3);

And this gives me:

enter image description here

And this is exactly what I want, with the exception that the values in the colorbar have changed...How can I do the same thing without changing the values in the colorbar?

Thank you for any help =)

like image 592
jjepsuomi Avatar asked Jul 25 '13 07:07

jjepsuomi


People also ask

How do I change the color of my Colorbar in Matlab?

You can change the color scheme by specifying a colormap. Colormaps are three-column arrays containing RGB triplets in which each row defines a distinct color. For example, here is a surface plot with the default color scheme. f = figure; surf(peaks);

What is the default colormap in Matlab?

If you have not specified a different default value, then the default colormap is parula .


1 Answers

why wont you just invert the colormap by flipping up-down (flipud)? For example:

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

or in a more compact way:

imagesc(your_image);
colormap(flipud(gray))
like image 120
bla Avatar answered Sep 26 '22 23:09

bla