필터 지우기
필터 지우기

How to have colourful contours superimposed on a grayscale (imshow) background?

조회 수: 3 (최근 30일)
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

채택된 답변

Chad Greene
Chad Greene 2016년 5월 12일
편집: Chad Greene 2016년 5월 12일
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))

추가 답변 (1개)

Zohreh Khazraei Manesh
Zohreh Khazraei Manesh 2016년 5월 13일
편집: Zohreh Khazraei Manesh 2016년 5월 13일
Thank you for your super fast response Chad!
The solution is smart and works perfectly!

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by