Plot pixels from 2D boolean array

조회 수: 46 (최근 30일)
Radhika Kulkarni
Radhika Kulkarni 2019년 11월 30일
답변: Radhika Kulkarni 2019년 12월 2일
I have a 2D boolean array stored 0s and 1s where I want to plot a red pixel. For example, If the 2D boolean array has 1 for (20, 20) location, it should plot a red pixel at that location. Else, it is has 0, it should not plot the red pixel.
Can someone help me?
  댓글 수: 1
Radhika Kulkarni
Radhika Kulkarni 2019년 11월 30일
2D Boolean Array is size 101x101

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

채택된 답변

Stephan
Stephan 2019년 11월 30일
% your array
A = randi(2,101)-1;
% the result;
R=255*ones(101);
G=255*(-A+1);
B=255*(-A+1);
res = cat(3,R,G,B);
% plot result
imshow(res)
  댓글 수: 4
Radhika Kulkarni
Radhika Kulkarni 2019년 11월 30일
편집: Radhika Kulkarni 2019년 11월 30일
Great! It worked.
Now, It is plotting my image from the array. I need to rotate the axes by 135 deg CCW. How do I do that?
See the attachment. I need to rotate this by 135 deg CCW.
Stephan
Stephan 2019년 11월 30일
편집: Stephan 2019년 11월 30일
If you have Image Processing Toolbox use imrotate. If not see FEX to download a tool.

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

추가 답변 (2개)

Radhika Kulkarni
Radhika Kulkarni 2019년 11월 30일
One more thing, I need to put this in a some time refresh loop, so it grows in size and back to normal size. Like pumping heart.
  댓글 수: 1
Stephan
Stephan 2019년 11월 30일
On File Exchange there are also tools to create gif animations. Maybe you want to use this.

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


Radhika Kulkarni
Radhika Kulkarni 2019년 12월 2일
How can I also show the x & y axis and ticks and axis data points to plot along with this vectorized code?

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by