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

B Furtado
  • 1,488
  • 3
  • 20
  • 34

1 Answers1

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()
Community
  • 1
  • 1
Maxwell Grady
  • 306
  • 4
  • 12