Interface2017年05月号新画像処理101を読む

4-5 垂直方向に揺らめかせる「サイン揺らぎ(垂直)」

img_src = cv2.imread("data/img_4-5.bmp")

#振幅
A = 50
#dst画像用意
img_dst = np.zeros_like(img_src)

Y = img_src.shape[0]
X = img_src.shape[1]

for y in range(Y):
    for x in range(X):
        x2 = int(x + A*np.sin(np.pi*y/180))
        if x2 < 959:
            img_dst[y,x2] = img_src[y,x]

#描画する
cv2.imshow("img_src",img_src)
cv2.imshow("img_dst",img_dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

f:id:bitop:20180227114202p:plain

f:id:bitop:20180227114246p:plain