![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174293/image.png)
How to have colourful contours superimposed on a grayscale (imshow) background?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zohreh Khazraei Manesh
am 12 Mai 2016
Kommentiert: Chad Greene
am 13 Mai 2016
Hi! I need to create contours (with the ordinary colorbar) superimposed on a grayscale image, which I have plotted using imshow. The contours tend to appear in white. Is there any way to give them colours?
Here is my code:
Brain=load('Raw.mat');
background=mat2gray(Brain(:,:,26));
figure
imshow(background)
hold on
densities=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8000];
contour(volume(:,:,26),densities)
hold off
0 Kommentare
Akzeptierte Antwort
Chad Greene
am 12 Mai 2016
Bearbeitet: Chad Greene
am 12 Mai 2016
Here's one way. If you turn the background matrix into RGB values, imshow won't try to attach the background image to the current colormap.
bg = ind2rgb(imread('cameraman.tif'),gray(256));
imshow(bg)
hold on
contour(peaks(256))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174293/image.png)
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Red finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!