本文整理汇总了Python中PythonMagick.Image.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Image.copy方法的具体用法?Python Image.copy怎么用?Python Image.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonMagick.Image
的用法示例。
在下文中一共展示了Image.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: align
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import copy [as 别名]
rx1,ry1,rx2,ry2,rs = rotate_points
rot1_data = img[ry1-rs:ry1+rs+1,rx1-rs:rx1+rs+1,:].mean(axis=2)
rot2_data = img[ry2-rs:ry2+rs+1,rx2-rs:rx2+rs+1,:].mean(axis=2)
rotate_angle = 180*math.atan2((ry2-ry1),(rx2-rx1))/math.pi
if rotate_angle is not 0:
print "Rotation angle is %3.3f deg" % rotate_angle
img = ndimage.rotate(img, rotate_angle, reshape=False)
# If the base-image got rotated, we need to align it so
# that the reference point is in the correct place
b,xb,yb = align(img.mean(axis=2), align_ref_data, area=align_search_area)
tx = align_ref_loc[0] - xb # translation in x-direction
ty = align_ref_loc[1] - yb # translation in y-direction
print "Shift: x: %d, y: %d, correlation (R^2): %1.3f" % (tx,ty,b)
n_x1,n_x2,n_y1,n_y2,o_x1,o_x2,o_y1,o_y2 = calc_align_area(tx,ty,w,h)
# Move image data by the calculated amount
n_img = 0*img.copy()
n_img[n_y1:n_y2,n_x1:n_x2,:] = img[o_y1:o_y2,o_x1:o_x2,:]
img = n_img.copy()
# Calculate normalization value, or normalize the base image to given value
if normalization is not None:
if normalization_area is None:
normalization_area = (0,0,w,h)
x1,y1,x2,y2 = normalization_area
if normalization > 0:
if verbose:
print "Normalizing to %d" % normalization
img_tmp = img*(1.0*normalization/np.median(img[y1:y2,x1:x2,:].mean(axis=2)))
if img.dtype == 'uint16':
img_tmp[img_tmp > 2**16 - 1] = 2**16 - 1