def create_image_matrix(self, degrees=180):
"""
This creates a 3d matrix of an image with rotations acting in the xy plane
This code is not yet integrated into the menu, but it works. It needs
to be able to take user text input to create transformation matrices that
can act on any volume data.
"""
width = self.matrix_size
rows,cols = self.img_cp.shape #Image cp is the compressed image.
v = np.zeros((width, width, width))
for z in range(width):
M = cv2.getRotationMatrix2D((cols/2,rows/2),z*degrees/width,1) #This finds the rotation matirx
dyn_img = cv2.resize(image, (int(np.cos(z/width)*width+10), width-z+10)) #Resizes the image throughout the z axis based on a mathematical function.
dst = cv2.warpAffine(dyn_img, M,(cols/2,rows/2)) #This applies the rotation matrix to the image.
v[:][z][:] += cv2.warpAffine(dyn_img,M,(cols,rows))
v = np.lib.pad(v, ((1,1),(1,1),(1,1)), 'constant') #This padds the z axis with zero's arrays so that a closed shape is produced by create_iso_surface.
return v
sculpture_gen.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录