1

I'm trying to warp two images of different sizes using PIL; specifically, by setting the shape (size) for future warped target image as a numpy array and I'm encountering AttributeError:

File "C:\Anaconda2\lib\site-packages\PIL\Image.py", line 632, in getattr raise AttributeError(name) AttributeError: shape

Why does this happen? I'm under the impression that I was doing this exact thing some time ago and it was working just fine, not to mention the fact that I absolutely don't understand what is it that python doesn't understand (the shape attribute should take this as an input with no problem)

import skimage.io
from PIL import Image
import numpy as np


Img1 = Image.open(picture1 + ".png") 
Img1

Img2 = Image.open(picture2 + ".png")
Img2

r, c = Img2.shape[:2]

    # creates array for the future shape in x,y
corners = np.array([[0, 0],
                    [0, r],
                    [c, 0],
                    [c, r]])
...

Regards, JJ

1 Answer 1

1

I think Image objects have size attributes and arrays have shape attributes. Try renaming it in your code. (See : http://effbot.org/imagingbook/image.htm)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.