本文整理匯總了Python中cv2.pyrDown方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.pyrDown方法的具體用法?Python cv2.pyrDown怎麽用?Python cv2.pyrDown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cv2
的用法示例。
在下文中一共展示了cv2.pyrDown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def pyramid(image, minSize):
yield image
if image.shape[0] < minSize[0] and image.shape[1] < minSize[1]:
# image too small - upscaling until we hit window level
image = cv2.pyrUp(image)
while (image.shape[0] <= minSize[0] or image.shape[1] <= minSize[1]):
yield image
image = cv2.pyrUp(image)
else:
# image too big - downscaling until we hit window level
image = cv2.pyrDown(image)
while (image.shape[0] >= minSize[0] or image.shape[1] >= minSize[1]):
yield image
image = cv2.pyrDown(image)
# Malisiewicz et al.
示例2: compute_disparity_pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def compute_disparity_pyramid(self):
self.disparity = []
stereo = cv2.StereoBM_create()
# stereo = cv2.StereoSGBM_create(minDisparity=0,
# numDisparities=64,
# blockSize=11)
# Compute disparity at full resolution and downsample
disp = stereo.compute(self.im_left, self.im_right).astype(float) / 16.
for pyrlevel in range(self.pyrlevels):
if pyrlevel == 0:
self.disparity = [disp]
else:
pyr_factor = 2**-pyrlevel
# disp = cv2.pyrDown(disp) # Applies a large Gaussian blur
# kernel!
disp = disp[0::2, 0::2]
self.disparity.append(disp * pyr_factor)
示例3: cartoonise
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def cartoonise(self, img_rgb, num_down, num_bilateral, medianBlur, D, sigmaColor, sigmaSpace):
# 用高斯金字塔降低取樣
img_color = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2BGR)
for _ in range(num_down):
img_color = cv2.pyrDown(img_color)
# 重複使用小的雙邊濾波代替一個大的濾波
for _ in range(num_bilateral):
img_color = cv2.bilateralFilter(img_color, d=D, sigmaColor=sigmaColor, sigmaSpace=sigmaSpace)
# 升采樣圖片到原始大小
for _ in range(num_down):
img_color = cv2.pyrUp(img_color)
if not self.Save_Edge:
img_cartoon = img_color
else:
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2GRAY)
img_blur = cv2.medianBlur(img_gray, medianBlur)
img_edge = cv2.adaptiveThreshold(img_blur, 255,
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY,
blockSize=self.Adaptive_Threshold_Block_Size,
C=self.C)
img_edge = cv2.cvtColor(img_edge, cv2.COLOR_GRAY2RGB)
img_edge = cv2.resize(img_edge, img_color.shape[:2][::-1])
img_cartoon = cv2.bitwise_and(img_color, img_edge)
return cv2.cvtColor(img_cartoon, cv2.COLOR_RGB2BGR)
示例4: compute_orb_keypoints
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def compute_orb_keypoints(filename):
"""
Takes in filename to read and computes ORB keypoints
Returns image, keypoints and descriptors
"""
img = cv2.imread(filename)
img = cv2.pyrDown(img)
img = cv2.pyrDown(img)
# img = cv2.pyrDown(img)
# img = cv2.pyrDown(img)
# create orb object
orb = cv2.ORB_create()
# set parameters
orb.setScoreType(cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
orb.setWTA_K(3)
kp = orb.detect(img,None)
kp, des = orb.compute(img, kp)
return img,kp, des
示例5: build_lappyr
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def build_lappyr(img, leveln=6, dtype=np.int16):
img = dtype(img)
levels = []
for i in xrange(leveln-1):
next_img = cv2.pyrDown(img)
img1 = cv2.pyrUp(next_img, dstsize=getsize(img))
levels.append(img-img1)
img = next_img
levels.append(img)
return levels
示例6: _build_pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def _build_pyramid(self, image, levels):
""" Returns a list of reduced-size images, from smallest to original size """
pyramid = [image]
for l in range(levels-1):
if any(x < 20 for x in pyramid[-1].shape[:2]):
break
pyramid.append(cv2.pyrDown(pyramid[-1]))
return list(reversed(pyramid))
示例7: GaussianPyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def GaussianPyramid(img, leveln):
GP = [img]
for i in range(leveln - 1):
GP.append(cv2.pyrDown(GP[i]))
return GP
示例8: LaplacianPyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def LaplacianPyramid(img, leveln):
LP = []
for i in range(leveln - 1):
next_img = cv2.pyrDown(img)
LP.append(img - cv2.pyrUp(next_img, img.shape[1::-1]))
img = next_img
LP.append(img)
return LP
示例9: FMCreateGaussianPyr
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def FMCreateGaussianPyr(self, src):
dst = list()
dst.append(src)
for i in range(1, 9):
nowdst = cv2.pyrDown(dst[i-1])
dst.append(nowdst)
return dst
# taking center-surround differences
示例10: getRGB
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def getRGB(self,rgb):
self.rgb=rgb
#self.down=cv2.pyrDown(rgb)
self.down[:,:,:]=self.rgb[:,:,:]
#print self.down.shape
#self.down.shape=(150,200)
示例11: main
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def main():
image = cv2.imread("../data/4.2.03.tiff", 1)
first_layer_down = cv2.pyrDown(image)
first_layer_up = cv2.pyrUp(first_layer_down)
laplasian = cv2.subtract(image, first_layer_up)
cv2.imshow("Orignal Image", image)
cv2.imshow("Laplasian Image", laplasian)
cv2.waitKey(0)
cv2.destroyAllWindows()
示例12: compute_image_pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def compute_image_pyramid(self, pyrimage):
"""Compute an image pyramid."""
for pyrlevel in range(self.pyrlevels):
if pyrlevel == 0:
im_pyr = [pyrimage]
else:
im_pyr.append(cv2.pyrDown(im_pyr[-1]))
self.im_pyr = [im.astype(float) / 255. for im in im_pyr]
示例13: downsample
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def downsample(input, factor):
for _ in xrange(factor):
input = cv2.pyrDown(input)
return input
示例14: double_downsampling
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def double_downsampling(input):
return cv2.pyrDown(cv2.pyrDown(input))
示例15: get_image_diff
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrDown [as 別名]
def get_image_diff (img1, img2):
"""
Function: get_image_diff
------------------------
given two images, this finds the eroded/dilated difference
between them on a coarse grain.
NOTE: assumes both are full-size, color
"""
#=====[ Step 1: convert to gray ]=====
img1_gray = cv2.cvtColor (img1, cv2.COLOR_BGR2GRAY)
img2_gray = cv2.cvtColor (img2, cv2.COLOR_BGR2GRAY)
#=====[ Step 2: downsample ]=====
img1_small = cv2.pyrDown(cv2.pyrDown(img1_gray))
img2_small = cv2.pyrDown(cv2.pyrDown(img2_gray))
#=====[ Step 3: find differnece ]=====
difference = img2_small - img1_small
#=====[ Step 4: erode -> dilate ]=====
kernel = np.ones ((4, 4), np.uint8)
difference_ed = cv2.dilate(cv2.erode (difference, kernel), kernel)
#=====[ Step 5: blow back up ]=====
return cv2.pyrUp (cv2.pyrUp (difference_ed))
####################################################################################################
##############################[ --- CORNER DETECTION/DESCRIPTION--- ]###############################
####################################################################################################