pip主页:https://pypi.org/project/imutils/
github主页:https://github.com/jrosebr1/imutils
功能包括:
1.最简单的图像变换
bridge = cv2.imread("../demo_images/bridge.jpg")
cactus = cv2.imread("../demo_images/cactus.jpg")
logo = cv2.imread("../demo_images/pyimagesearch_logo.jpg")
workspace = cv2.imread("../demo_images/workspace.jpg")
# translate the image x-50 pixels to the left and y=100 pixels down
translated = imutils.translate(workspace, -50, 100)
cv2.imshow("Translated", translated)
cv2.waitKey(0)
# rotate the image and display it
rotated = imutils.rotate(bridge, angle=60)
cv2.imshow("Angle=%d" % (angle), rotated)
# wait for a keypress, then close all the windows
cv2.waitKey(0)
cv2.destroyAllWindows()
# resize the image and display it
resized = imutils.resize(workspace, width=321,height=123)
cv2.imshow("Width=%dpx" % (width), resized)
# wait for a keypress, then close all the windows
cv2.waitKey(0)
cv2.destroyAllWindows()
以及
def skeletonize(image, size, structuring=cv2.MORPH_RECT) #灰度骨架提取
def opencv2matplotlib(image): #opencv默认图片是GBR通道
def url_to_image(url, readFlag=cv2.IMREAD_COLOR): #URL连接保存为图片
def auto_canny(image, sigma=0.33): #边缘提取
def build_montages(image_list, image_shape, montage_shape):
2.base64编解码
def base64_encode_image(a):
def base64_decode_image(a):
def base64_encode_array(a):
def base64_decode_array(a, dtype):
3.展示目录下的所有文件
def list_files(basePath, validExts=(".jpg", ".jpeg", ".png", ".bmp", ".tif", ".tiff"), contains=None):
4.排序勾勒轮廓
def sort_contours(cnts, method="left-to-right"):
4.四点透视变换
def four_point_transform(image, pts):
其他
README.md和/demo/×均有示例和说明