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 Exchange에서 Geometric 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