imshow - plotting a circular image, how to make corners white?

조회 수: 1 (최근 30일)
Michael
Michael 2012년 4월 26일
Hi
I have a circular image but it's stored as a grayscale matrix, ie. square. When I use "imshow" with the jet colormap it automatically makes the areas outside the circle blue (because the matrix elements are all 0s).
Is there a fix for this? I want the areas outside the circle to be white, or not plotted, without messing with the colormap (which then ruins the colorbar).
Thanks for any help
Mike

답변 (2개)

Junaid
Junaid 2012년 4월 26일
Could you share your matrix. Or try following command.
colormap gray;
This will make show boundary either black or white.

Image Analyst
Image Analyst 2012년 4월 26일
Just adjust the colormap:
% Start with the jet colormap.
cmap = jet(256);
% Change 0 from blue to white.
% Gray level of zero will now show up as white rather than blue.
cmap(0,:) = [1 1 1];
% Apply the colormap (a modified jet colormap).
colormap(cmap);
  댓글 수: 1
Michael
Michael 2012년 4월 26일
This works, although I have two side-effects, first, the genuine 0 values within the circle appear as white regions (not blue), and also the colorbar is distorted.
I was hoping for an alternative method that doesn't involve this kind of fiddling, because now I have to change the image boundaries and the colorbar properties I think
Thanks for the reply

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by