We present theoretical studies on the wideband design of bulk lithium niobate (LN) acousto-optic deflector (AOD) through the walk-off design of the ultrasonic vector, which satisfies the momentum match condition. The ultrasonic properties of LN cryst
Due to the existence of spatial walk-off and/or group-velocity mismatch effects, pump-to-signal phase transfer becomes inevitable during parametric amplification. We experimentally demonstrate that in hybrid seeded optical parametric amplifiers (OPAs
上一篇文章中,我们介绍了python实现图片处理和特征提取详解,这里我们再来看看Python通过OpenCV实现批量剪切图片,具体如下。
做图像处理需要大批量的修改图片尺寸来做训练样本,为此本程序借助opencv来实现大批量的剪切图片。
import cv2
import os
def cutimage(dir,suffix):
for root,dirs,files in os.walk(dir):
for file in files:
filepath = os.path.jo
今天用Python提取了Linux内核源代码的目录树结构,没有怎么写过脚本程序,我居然折腾了2个小时,先是如何枚举出给定目录下的所有文件和文件夹,os.walk可以实现列举,但是os.walk是只给出目录名和文件名,而没有绝对路径。使用os.path.listdir可以达到这个目的,然后是创建目录,由于当目录存在是会提示创建失败的错误,所以我先想删除所有目录,然后再创建,但是发现还是有问题,最好还是使用判断如果不存在才创建目录,存在时就不创建,贴下代码:
# This scr ipt can
有一个比较大的数据集需要自己处理,在分出训练集和测试集时,如果靠手动实在太麻烦,于是自己写了一段代码。(其实就是在某一路径下的子文件夹里取出符合要求的图片,放到另一个路径的对应文件夹中)
from PIL import Image
import os
import glob
def read_image(cwd,newpath):
for roots,dirs,files in os.walk(cwd):
print(dirs)
for i in dirs:
print(i)