当前位置: 首页>>代码示例>>Python>>正文


Python cv2.pyrDown方法代码示例

本文整理汇总了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. 
开发者ID:AVGInnovationLabs,项目名称:DoNotSnap,代码行数:22,代码来源:util.py

示例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) 
开发者ID:utiasSTARS,项目名称:pyslam,代码行数:21,代码来源:keyframes.py

示例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) 
开发者ID:MashiMaroLjc,项目名称:rabbitVE,代码行数:27,代码来源:Cartoonlization.py

示例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 
开发者ID:PacktPublishing,项目名称:Practical-Computer-Vision,代码行数:24,代码来源:04_feature_match.py

示例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 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:12,代码来源:lappyr.py

示例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)) 
开发者ID:glitchassassin,项目名称:lackey,代码行数:10,代码来源:TemplateMatchers.py

示例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 
开发者ID:cynricfu,项目名称:dual-fisheye-video-stitching,代码行数:7,代码来源:blending.py

示例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 
开发者ID:cynricfu,项目名称:dual-fisheye-video-stitching,代码行数:10,代码来源:blending.py

示例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 
开发者ID:tyarkoni,项目名称:pliers,代码行数:10,代码来源:pySaliencyMap.py

示例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) 
开发者ID:akash0x53,项目名称:virtual-dressing-room,代码行数:9,代码来源:normalized.py

示例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() 
开发者ID:amarlearning,项目名称:Finger-Detection-and-Tracking,代码行数:15,代码来源:Pyramids.py

示例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] 
开发者ID:utiasSTARS,项目名称:pyslam,代码行数:12,代码来源:keyframes.py

示例13: downsample

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrDown [as 别名]
def downsample(input, factor):
  for _ in xrange(factor):
    input = cv2.pyrDown(input)
  return input 
开发者ID:nsavinov,项目名称:SPTM,代码行数:6,代码来源:util.py

示例14: double_downsampling

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import pyrDown [as 别名]
def double_downsampling(input):
  return cv2.pyrDown(cv2.pyrDown(input)) 
开发者ID:nsavinov,项目名称:SPTM,代码行数:4,代码来源:util.py

示例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--- ]###############################
#################################################################################################### 
开发者ID:nebbles,项目名称:DE3-ROB1-CHESS,代码行数:36,代码来源:CVAnalysis_old.py


注:本文中的cv2.pyrDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。