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

8 visualizaciones (últimos 30 días)
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);

Respuesta aceptada

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

Más respuestas (1)

DGM
DGM el 30 de Dic. de 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.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by