Can I have rotate image with white background
By default if we use imrotate it rotate image with black background can I have rotated image with white background?

 採用された回答

Sean de Wolski
Sean de Wolski 2011 年 6 月 23 日

5 投票

Irot = imrotate(I,theta);
Mrot = ~imrotate(true(size(I)),theta);
Irot(Mrot&~imclearborder(Mrot)) = 255;
%View 'er
imtool(Irot)
Edited to be more robust/simpler

4 件のコメント

Dipak
Dipak 2011 年 6 月 24 日
Hi sean First of all Thankyou very much for giving me the ans.
priya7 D Mello
priya7 D Mello 2012 年 2 月 23 日
Thank you very much. I needed this code badly for my project :)
Leo Wong
Leo Wong 2018 年 9 月 5 日
You are a genius Sean. Your code was the missing piece to complete my project :)
Ali RAHIMI KHOJASTEH
Ali RAHIMI KHOJASTEH 2021 年 4 月 1 日
Thank you, it works for me

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

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 6 月 23 日

1 投票

imrotate() always fills with 0.
If your image is floating point, then one way to proceed would be to put a border of NaN around your image, and rotate that. The resulting image should have NaN in it; set the NaN and everything outside to the background color you want.

1 件のコメント

Dipak
Dipak 2011 年 6 月 24 日
Thanks Walter For the reply.
Thank you.

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

カテゴリ

ヘルプ センター および File ExchangeGeometric Transformation and Image Registration についてさらに検索

質問済み:

2011 年 6 月 23 日

回答済み:

DGM
2023 年 12 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by