Image rotate
조회 수: 1 (최근 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?
댓글 수: 0
채택된 답변
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
2018년 9월 5일
You are a genius Sean. Your code was the missing piece to complete my project :)
추가 답변 (2개)
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!