Imrotate help - black pixel border remains despite changing the colour of the background?

7 views (last 30 days)
Hello,
With the imrotate function, the negative space of the image is automatically replaced with black. My attached script works great and changes this to the colour I need -- grey. However, if the rotation is not along a right angle, a tiny border of black pixels remains (see attached image). Please tell me there is a way to remove them?
Thanks in advance for your help.
RGB = imread('wheel_final.jpg');
rotationdegree = randi(360);
RGB_Rotated = imrotate(RGB,rotationdegree,'bilinear','crop');
Mrot = ~imrotate(true(size(RGB)), rotationdegree,'bilinear','crop');
RGB_Rotated(Mrot&~imclearborder(Mrot))=150;
imtool(RGB_Rotated);

Accepted Answer

Image Analyst
Image Analyst on 11 Nov 2016
Try the nearest option instead of the bilinear option.

More Answers (1)

DGM
DGM on 30 Dec 2023
This answer covers mulptile approaches to controlling the padding color, and the halo left by simple workarounds is addressed without needing to resort to sacrificing interpolation.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!