Dưới đây là các ví dụ về sơ đồ api python. biến đổi. xoay lấy từ các dự án mã nguồn mở. Bằng cách bỏ phiếu, bạn có thể chỉ ra ví dụ nào hữu ích và phù hợp nhất
10 ví dụ 7
3
ví dụ 1
Dự án. scikit-image
Giấy phép. Xem giấy phép
Tệp nguồn. test_warps. p
def test_rotate_resize[]:
x = np.zeros[[10, 10], dtype=np.double]
x45 = rotate[x, 45, resize=False]
assert x45.shape == [10, 10]
x45 = rotate[x, 45, resize=True]
# new dimension should be d = sqrt[2 * [10/2]^2]
assert x45.shape == [14, 14]
3
ví dụ 2
Dự án. scikit-image
Giấy phép. Xem giấy phép
Tệp nguồn. test_warps. p
def test_rotate_center[]:
x = np.zeros[[10, 10], dtype=np.double]
x[4, 4] = 1
refx = np.zeros[[10, 10], dtype=np.double]
refx[2, 5] = 1
x20 = rotate[x, 20, order=0, center=[0, 0]]
assert_almost_equal[x20, refx]
x0 = rotate[x20, -20, order=0, center=[0, 0]]
assert_almost_equal[x0, x]
3
ví dụ 3
Dự án. scikit-image
Giấy phép. Xem giấy phép
Tệp nguồn. test_warps. p
def test_rotate_resize_center[]:
x = np.zeros[[10, 10], dtype=np.double]
x[0, 0] = 1
ref_x45 = np.zeros[[14, 14], dtype=np.double]
ref_x45[6, 0] = 1
ref_x45[7, 0] = 1
x45 = rotate[x, 45, resize=True, center=[3, 3], order=0]
# new dimension should be d = sqrt[2 * [10/2]^2]
assert x45.shape == [14, 14]
assert_equal[x45, ref_x45]
3
Ví dụ 4
Dự án. gconv_experiments
Giấy phép. Xem giấy phép
Tệp nguồn. gia tăng. p
def rotate_transform_batch[x, rotation=None]:
r = np.random.uniform[-0.5, 0.5, size=x.shape[0]] * rotation
# hack; skimage.transform wants float images to be in [-1, 1]
factor = np.maximum[np.max[x], np.abs[np.min[x]]]
x = x / factor
x_out = np.empty_like[x]
for i in range[x.shape[0]]:
x_out[i, 0] = tf.rotate[x[i, 0], r[i]]
x_out *= factor
return x_out
3
Ví dụ 5
Dự án. seya
Giấy phép. Xem giấy phép
Tệp nguồn. data_utils. p
def _allrotations[self, image]:
angles = np.linspace[0, self.final_angle, self.n_steps]
R = np.zeros[[self.n_steps, np.prod[self.img_shape]]]
for i in xrange[self.n_steps]:
img = rotate[image, angles[i]]
if len[self.img_shape] == 3:
img = img.transpose[2, 0, 1]
R[i] = img.flatten[]
return R
0
Ví dụ 6
Dự án. scikit-image
Giấy phép. Xem giấy phép
Tệp nguồn. test_warps. py
Hàm. kiểm tra_xoay
def test_rotate[]:
x = np.zeros[[5, 5], dtype=np.double]
x[1, 1] = 1
x90 = rotate[x, 90]
assert_almost_equal[x90, np.rot90[x]]
0
Ví dụ 7
Dự án. skipage-demos
Giấy phép. Xem giấy phép
Tệp nguồn. lẫn nhau_thông tin. py
Hàm. update_angle
def update_angle[self, name, angle]:
self.image = rotate[self.original_image, angle]
self.histogram.draw[angle=angle]
0
Ví dụ 8
Dự án. kaggle-galaxies
Giấy phép. Xem giấy phép
Tệp nguồn. tải dữ liệu. p
def im_rotate[img, angle]:
return skimage.transform.rotate[img, angle, mode='reflect']
0
Ví dụ 9
Dự án. VIP
Giấy phép. Xem giấy phép
Tệp nguồn. làm giảm giá trị. p
0
Ví dụ 10
Dự án. kaggle-right-whale
Giấy phép. Xem giấy phép
Tệp nguồn. điểm_crop. p
def get_head_crop[img, pt1, pt2]:
im = img.copy[]
minh = 10
minw = 20
x = pt1[0] - pt2[0]
y = pt1[1] - pt2[1]
dist = math.hypot[x, y]
croph = int[[im.shape[0] - 1.0 * dist] // 2]
cropw = int[[im.shape[1] - 2.0 * dist] // 2]
newh = im.shape[0] - 2 * croph
neww = im.shape[1] - 2 * cropw
if croph