最近看到二维傅立叶图像变换,其中提到了莫尔纹。生活当中莫尔纹很容易见到,就像用python显示出来。于是写了一段代码。
import cv2 as cv
import numpy as np
import matplotlib.pyplot as pyplot
img1=np.zeros([200,200],np.uint8)
[w,h] = img1.shape
for i in range(0,w):
for j in range(0,h):
if int(j / 5) % 2 == 0:
img1[i,j] = 255
pyplot.imshow(img1,cmap='gray')
<matplotlib.image.AxesImage at 0x13727f310>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yZzevzbJ-1590672698492)(output_6_1.png)]
img2=np.zeros([200,200],np.uint8)
for i in range(0,w):
for j in range(0,h):
if int(j / 7) % 2 == 0:
img2[i,j] = 255
pyplot.imshow(img2,cmap='gray')
<matplotlib.image.AxesImage at 0x10a938ed0>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZdQ1Ebjx-1590672698493)(output_9_1.png)]
imgRotateM = cv.getRotationMatrix2D((100,100),30,0.7)
imgRotate = cv.warpAffine(img2,imgRotateM,(200,200))
pyplot.imshow(imgRotate,cmap='gray')
<matplotlib.image.AxesImage at 0x10aa29510>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TMCxg7fu-1590672698494)(output_12_1.png)]
imgMerge = 0.5 * img1 + 0.5 * imgRotate
pyplot.imshow(imgMerge,cmap='gray')
<matplotlib.image.AxesImage at 0x1375b30d0>
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xTACLmVw-1590672698494)(output_14_1.png)]
去github
https://github.com/LuckilyHaveYou/LearningCode/blob/master/图像的莫尔纹效应.ipynb
网友评论