save the output figure as binary image

10 ビュー (過去 30 日間)
mohammed alany
mohammed alany 2020 年 2 月 16 日
コメント済み: mohammed alany 2020 年 2 月 17 日
i am plotting rectangle like in the code bellow,
rectangle('Position',[96 539-450 214 161], 'FaceColor',[0 .5 .5])
axis([0 559 0 539])
i want to save the output figure as binary image "in workspace" without border and exact area.
as a result the binary image must be like 559x539
any help?
  2 件のコメント
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 16 日
Use this
[rows, cols, channels] = size(img)

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

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 2 月 16 日
編集済み: Subhadeep Koley 2020 年 2 月 16 日
The below code will save the figure as an image in the worksapce.
clc; close all;
rectangle('Position',[0 0 539 539], 'FaceColor',[0 .5 .5],...
'LineStyle', 'none');
axis tight; axis off;
frm = getframe(gcf);
img = frame2im(frm);
img = imresize(img, [539, 539], 'bicubic');
figure; imshow(img);
But, if you convert the image to binary (as you stated in your question) then all the color information (which you added using FaceColor) will be lost. And the image will become a black blob.
  8 件のコメント
mohammed alany
mohammed alany 2020 年 2 月 17 日
@image analyst @subhadeep koley Thanks for your reply, but can you please write me the exact code? What you mean by burn

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by