getting an image matrix when I have the image.

9 ビュー (過去 30 日間)
David Epstein
David Epstein 2018 年 7 月 20 日
コメント済み: Image Analyst 2018 年 7 月 21 日
My code to produce a white F on a black background:
f_shape = [0,0;1,0;1,2;2,2;2,3;1,3;1,5;3,5;3,6;0,6;0,0]*[1,0;0,-1];
r = ceil(max(range(f_shape))*sqrt(2));
kappa =2;
R = ceil(kappa*r);
f_img = zeros(2*R);
f_shape = f_shape + R*[1,1];
imshow(f_img);
hold;
fill(f_shape(:,1),f_shape(:,2),'w');
daspect = [1,1,1];
Now I want to apply imrotate to this 36 times 36 image matrix. The only way I can think of is to save it as a png, and then imread it. Do I really have to do that? Sound slow, and wrong in principle. It is also likely to result in lots of pointless files littering my hard disk.

採用された回答

Image Analyst
Image Analyst 2018 年 7 月 20 日
Simply call imrotate() on f_img. Why do you think you can't do that???
rotatedImage = imrotate(f_img, angle);
  4 件のコメント
David Epstein
David Epstein 2018 年 7 月 21 日
Thanks for the explanation. I had assumed that the graphics commands would change the matrix directly. This clarifies the issue for a naive user like me. I was interested to see how the shape changes when rotated, and I'm planning to look up and use an interpolation method with imrotate, in the hope that the change won't be so obvious.
Image Analyst
Image Analyst 2018 年 7 月 21 日
You need to understand the concept of an actual digital image, which has pixel values, and the concept of a graphical overlay, where you put computer graphics in over the image. The Image Processing Toolbox commands, starting with im or bw, work on the image itself, not with anything you may have put on top of them in the overlay.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by