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

4-4 水平方向に揺らめかせる「サイン揺らぎ(水平)」

img_src = cv2.imread("data/img_4-4.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):
        y2 = int(y + A*np.sin(f*np.pi*x/180))
        if y2 < 639:
            img_dst[y2,x] = img_src[y,x]

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

ちょっと違ったが

f:id:bitop:20180225084803p:plain

f:id:bitop:20180225084830p:plain