5

I have a simple picture in Python 3.X I can display it. However, I cannot rotate it, using skimage.transform.rotate.

The error is that my 'Picture' object has no shape. I've seen the .shape included after the rotate command, but it still does not work.

Here is my code

import skimage
from skimage import novice

# New, all black picture
pic = skimage.novice.Picture.from_size((600, 600), color=(0, 0, 0))

# Coloring some pixels in white
for i in range(0, len(all_dots) - 1, 2):
    x = all_dots[i]
    y = all_dots[i + 1]
    pic[x, y] = (255, 255, 255)

from skimage.transform import rotate

new_pic = rotate(pic, 180)
# Also new_pic = rotate(pic, 180).shape does not work

new_pic.show()

Any ideas? Thanks

1 Answer 1

6

Would have to do some more testing but at first glance I'd say the problem is the first argument you are passing to the rotate() function.

According to the docs for Skimage: http://scikit-image.org/docs/stable/api/skimage.transform.html#rotate

rotate() takes a first argument an image in the format of ndarray. Your object (since you are using the 'novice' module, is of type according to my quick test.

Try something like:

new_pic = rotate(pic.array, 180)

pic.array is a direct reference to the underlying ndarray object stored in the novice 'Picture' object

EDIT: This gives you new_pic as numpy array! so you'll need to do the following to show it:

new_pic = rotate(pic.array, 180)

from skimage.io import imshow, show

imshow(new_pic)

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

1 Comment

Thanks! Not sure why I would need to make it an array before rotating it. But, it did work. Best,

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.