Image rotate

5 次查看(过去 30 天)
Dipak
Dipak 2011-6-23
回答: DGM 2023-12-30
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
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 个评论
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
Thank you, it works for me

请先登录,再进行评论。

更多回答(2 个)

Walter Roberson
Walter Roberson 2011-6-23
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.

请先登录,再进行评论。


DGM
DGM 2023-12-30

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by