필터 지우기
필터 지우기

Strange resultat using imagesc() on a three-value matrix

조회 수: 1 (최근 30일)
JFLabrie
JFLabrie 2017년 7월 13일
답변: JFLabrie 2017년 7월 14일
I want to have a three-color-only visual on a matrix that contains many values which are one of three values. Here is the simplest way I could repeat the issue:
r=rand(1,2000);
r(r>0.6)=70;r(r<=0.3)=0;r((r>0) & (r<70))=35;
figure;imagesc(r);
Zooming on some part of the image, I see more than three colors: uploaded_files/82867/sh_244.jpg
I would expect the visual to be in accordance with the values in the matrix. I mean, a visual with only 3 colors. Strangely, that does not happen if I replace the value 2000 by 1000 or by 2100. Is it my video card creating this bug? Or something else?
"Ver" returns:
  • MATLAB Version: 8.5.0.197613 (R2015a)
  • Operating System: Microsoft Windows 7 Édition Familiale Premium Version 6.1 (Build 7601: Service Pack 1)
  • Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot™ Client VM mixed mode
  댓글 수: 1
JFLabrie
JFLabrie 2017년 7월 13일
An even simpler code that leads to the same issue:
r=round(rand(1,2000));figure;imagesc(r);

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

채택된 답변

JFLabrie
JFLabrie 2017년 7월 14일
The following command solved the issue:
set(gcf,'Renderer', 'painters')

추가 답변 (2개)

Image Analyst
Image Analyst 2017년 7월 13일
I do not see that. I see only 3 colors in your first example, and two colors in your second example, as expected. My guess is it's your video adapter and how it's trying to zoom in, like by pixel replication (which would not introduce any new colors), or bicubic interpolation (which would introduce more colors).
  댓글 수: 1
JFLabrie
JFLabrie 2017년 7월 14일
Thank, it confirms to me that it is most likely hardware related.

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


Walter Roberson
Walter Roberson 2017년 7월 13일
  댓글 수: 1
JFLabrie
JFLabrie 2017년 7월 14일
I tried the following command without success:
set(gcf,'GraphicsSmoothing','off')
But your suggestion lead me to have a look at the Figure Properties. Then I tried the following command that solved the issue immediately:
set(gcf,'Renderer', 'painters')

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by