本文主要是介绍图片Gaussian pyramid(一),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
简介
偶然在一个网页上发现一个Python图像处理的方法,能够进行图片的缩放。首先进行了高斯滤波,当缩放到小于30×30时break。
helpers:
# import the necessary packages
from skimage.transform import pyramid_gaussian
import cv2
from PIL import Imageimage = Image.open('./image/cat2.jpg')
# METHOD #2: Resizing + Gaussian smoothing.
for (i, resized) in enumerate(pyramid_gaussian(image, downscale=2)):# if the image is too small, break from the loopif resized.shape[0] < 30 or resized.shape[1] < 30:break# show the resized imagecv2.imshow("Layer {}".format(i + 1), resized)cv2.waitKey(0)resized = resized*255cv2.imwrite('./'+WinName+'.jpg',resized[:,:,:])
使用Image.open效果
使用cv2.imread效果
参考
【1】Image Pyramids with Python and OpenCV - PyImageSearch
http://www.pyimagesearch.com/2015/03/16/image-pyramids-with-python-and-opencv/
【2】jrosebr1/imutils: A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.
https://github.com/jrosebr1/imutils
【3】Histogram of Oriented Gradients and Object Detection - PyImageSearch
http://www.pyimagesearch.com/2014/11/10/histogram-oriented-gradients-object-detection/
【4】Module: transform — skimage v0.14dev docs
http://scikit-image.org/docs/dev/api/skimage.transform.html#pyramid-gaussian
这篇关于图片Gaussian pyramid(一)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!