필터 지우기
필터 지우기

Image rotate

조회 수: 4 (최근 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
Ali RAHIMI KHOJASTEH 2021년 4월 1일
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에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by