필터 지우기
필터 지우기

Add colorbar of colored plot on grayscale image

조회 수: 5 (최근 30일)
Xiaozhun Tang
Xiaozhun Tang 2019년 5월 6일
댓글: Xiaozhun Tang 2019년 5월 7일
I have a grayscale image and draw a colored scatter plot on it,but the colorbar just vary from blcak to white,i wanna know how to show the colorbar of the scatter plot but not grayscale image.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 6일
Something like this:
% Assuming your grayscale image is: d in double format
grayscaleIM(:,:,3) = (d-min(d(:)))/(max(d(:))-min(d(:)));
grayscaleIM(:,:,2) = (d-min(d(:)))/(max(d(:))-min(d(:)));
grayscaleIM(:,:,1) = (d-min(d(:)))/(max(d(:))-min(d(:)));
figure
colormap(jet)
imagesc(x,y,grayscaleIM)
hold on
scatter(X,Y,23,V,'filled')
colorbar
Perhaps you have your data in some other formats but you can easily produce an RGB-image that only shows gray-scale or a binary black-white image regardless of what colourmap you use. Then the scatter-plot will work with the current colormap, as should the colorbar.
HTH
  댓글 수: 1
Xiaozhun Tang
Xiaozhun Tang 2019년 5월 7일
Thanks a lot for your answer! I achieve my aim by using your code. I used command 'imshow' to display the image before but without establishing RGB color-space like the first three lines of your code, so I produced a grayscale image or bingary image but not an RGB image. I ignore this before and I really appreciate your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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