本文整理汇总了Python中cv2.pyrUp方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.pyrUp方法的具体用法?Python cv2.pyrUp怎么用?Python cv2.pyrUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv2
的用法示例。
在下文中一共展示了cv2.pyrUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pyramid
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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: cartoonise
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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)
示例3: build_lappyr
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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
示例4: merge_lappyr
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def merge_lappyr(levels):
img = levels[-1]
for lev_img in levels[-2::-1]:
img = cv2.pyrUp(img, dstsize=getsize(lev_img))
img += lev_img
return np.uint8(np.clip(img, 0, 255))
示例5: process_scale
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def process_scale(a_lods, lod):
d = a_lods[lod] - cv2.pyrUp(a_lods[lod+1])
for i in xrange(lod):
d = cv2.pyrUp(d)
v = cv2.GaussianBlur(d*d, (3, 3), 0)
return np.sign(d), v
示例6: LaplacianPyramid
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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
示例7: reconstruct
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def reconstruct(LS):
img = LS[-1]
for lev_img in LS[-2::-1]:
img = cv2.pyrUp(img, lev_img.shape[1::-1])
img += lev_img
return img
示例8: main
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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()
示例9: double_upsampling
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def double_upsampling(input):
return cv2.pyrUp(cv2.pyrUp(input))
示例10: show_edges
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def show_edges (self):
# diff = (self.image_region_normalized - self.last_image_region_normalized)
# gray = cv2.cvtColor ()
# cv2.imshow ('NORMALIZED', cv2.pyrUp(cv2.pyrUp(np.abs(self.image_region_normalized - self.last_image_region_normalized))))
cv2.imshow ('EDGES', cv2.pyrUp(cv2.pyrUp(self.edges)))
cv2.imshow ('REGION', cv2.pyrUp(cv2.pyrUp(self.image_region)))
key = 0
while key != 27:
key = cv2.waitKey (30)
示例11: get_image_diff
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [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--- ]###############################
####################################################################################################
示例12: show_image
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def show_image (image, title):
cv2.imshow (title, cv2.pyrUp(cv2.pyrUp(image)))
示例13: LaplacianPyramid
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def LaplacianPyramid(self, img, level):
gp = self.GaussianPyramid(img, level)
lp = [gp[level-1]]
for i in range(level - 1, -1, -1):
GE = cv2.pyrUp(gp[i])
GE = cv2.resize(GE, (gp[i - 1].shape[1], gp[i - 1].shape[0]), interpolation=cv2.INTER_CUBIC)
L = cv2.subtract(gp[i - 1], GE)
lp.append(L)
return lp, gp
示例14: reconstruct
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def reconstruct(self, input_pyramid):
out = input_pyramid[0]
for i in range(1, len(input_pyramid)):
out = cv2.pyrUp(out)
out = cv2.resize(out, (input_pyramid[i].shape[1],input_pyramid[i].shape[0]), interpolation = cv2.INTER_CUBIC)
out = cv2.add(out, input_pyramid[i])
return out
示例15: main
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrUp [as 别名]
def main():
# read an image
img = cv2.imread('../figures/flower.png')
print(img.shape)
lower_resolution1 = cv2.pyrDown(img)
print(lower_resolution1.shape)
lower_resolution2 = cv2.pyrDown(lower_resolution1)
print(lower_resolution2.shape)
lower_resolution3 = cv2.pyrDown(lower_resolution2)
print(lower_resolution3.shape)
higher_resolution3 = cv2.pyrUp(lower_resolution3)
print(higher_resolution3.shape)
higher_resolution2 = cv2.pyrUp(higher_resolution3)
print(higher_resolution2.shape)
higher_resolution1 = cv2.pyrUp(higher_resolution2)
print(higher_resolution1.shape)
# Do plot
plot_lr_img(img, lower_resolution1, lower_resolution2, lower_resolution3)
plot_hy_img(lower_resolution3, higher_resolution3, higher_resolution2, higher_resolution1)