Skimage : rotate image and fill the new formed background
<p>When rotating an image using</p>

<pre><code>import skimage

result = skimage.transform.rotate(img, angle=some_angle, resize=True)
# the result is the rotated image with black 'margins' that fill the blanks
</code></pre>

<p>The algorithm rotates the image but leaves the newly formed background black and there is no way - using the rotate function - to choose the color of the newly formed background.</p>

<p>Do you have any idea how to do choose the color of the background before rotating an image?</p>

<p>Thank you.</p>

<p>if your pic is a gray picture,use <code>cval</code> ;
if pic is rgb ,no good way,blow code works:</p>

<pre><code>path3=r'C:\\Users\forfa\Downloads\1111.jpg'
img20=data.imread(path3)
import numpy as np
img3=transform.rotate(img20,45,resize=True,cval=0.1020544) #0.1020544 can be any unique float,the pixel outside your pic is [0.1020544]*3
c,r,k=img3.shape
for i in range(c):
    for j in range(r):
        if np.allclose(img3[i][j],[0.1020544]*3):
            img3[i][j]=[1,0,0]  #[1,0,0] is red pixel,replace pixel [0.1020544]*3  with red pixel [1,0,0]
</code></pre>

python skimage