Python Forum
rotating and resizing objects
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rotating and resizing objects
#1
Dear all,
I really need help. I have 3d array. Inside that array I have a few objects (ellipsoids) that are represented by the digit 1 (the rest are 0s). I want to rotate these objects by n degrees. And the re-size them. is it possible?
Any suggestions would be appreciated.
Reply
#2
Your post lacks information of how you are representing these objects
Reply
#3
Hi, my array is 0/1 array. Ellipses are represented by 1s. So it is a bunch of 1s to shape up an ellipse.
Thanks
Reply
#4
In 3d-case you'll need to define an axis around which rotation is performed. I think, you need to look
at the rotate helper function from SciPy package . Below, I wrote a minimal example of 2d-ellipse rotation around third (z) axis. Hope that helps.


from scipy.ndimage.interpolation import rotate
import numpy as np

x, y = np.linspace(-5, 5, 100), np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)

# lets make an ellipse (Z); the array will consist of bool values, you can easily convert them to 0/1
Z = np.bitwise_and(((X/2)**2 + (Y/3)**2 - 1) < 0.2, ((X/2)**2 + (Y/3)**2 - 1) > 0.0)

import matplotlib.pyplot as plt

plt.imshow(Z)
rotated_Z =rotate(Z, 45)

plt.imshow(rotated_Z)

plt.show()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter Pillow Resize Image Looks Choppy While Resizing AaronCatolico1 2 1,325 Jan-03-2023, 05:41 PM
Last Post: AaronCatolico1
  rotating image with Tkinter Frankduc 6 6,239 May-21-2022, 03:00 PM
Last Post: Frankduc
  rotating an array djwilson0495 3 2,007 Jan-08-2021, 01:18 AM
Last Post: Skaperen
Question How to make a button always stay on a point when resizing the window? _ShevaKadu 5 4,079 Nov-04-2020, 03:59 PM
Last Post: deanhystad
  Image : center and resizing vvv 1 11,985 May-14-2017, 03:41 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020