當前位置: 首頁>>代碼示例>>Python>>正文


Python cv2.pyrUp方法代碼示例

本文整理匯總了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. 
開發者ID:AVGInnovationLabs,項目名稱:DoNotSnap,代碼行數:22,代碼來源:util.py

示例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) 
開發者ID:MashiMaroLjc,項目名稱:rabbitVE,代碼行數:27,代碼來源:Cartoonlization.py

示例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 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:12,代碼來源:lappyr.py

示例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)) 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:8,代碼來源:lappyr.py

示例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 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:8,代碼來源:turing.py

示例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 
開發者ID:cynricfu,項目名稱:dual-fisheye-video-stitching,代碼行數:10,代碼來源:blending.py

示例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 
開發者ID:cynricfu,項目名稱:dual-fisheye-video-stitching,代碼行數:8,代碼來源:blending.py

示例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() 
開發者ID:amarlearning,項目名稱:Finger-Detection-and-Tracking,代碼行數:15,代碼來源:Pyramids.py

示例9: double_upsampling

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrUp [as 別名]
def double_upsampling(input):
  return cv2.pyrUp(cv2.pyrUp(input)) 
開發者ID:nsavinov,項目名稱:SPTM,代碼行數:4,代碼來源:util.py

示例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) 
開發者ID:nebbles,項目名稱:DE3-ROB1-CHESS,代碼行數:14,代碼來源:Square.py

示例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--- ]###############################
#################################################################################################### 
開發者ID:nebbles,項目名稱:DE3-ROB1-CHESS,代碼行數:36,代碼來源:CVAnalysis_old.py

示例12: show_image

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import pyrUp [as 別名]
def show_image (image, title):
	cv2.imshow (title, cv2.pyrUp(cv2.pyrUp(image))) 
開發者ID:nebbles,項目名稱:DE3-ROB1-CHESS,代碼行數:4,代碼來源:image_region_analysis.py

示例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 
開發者ID:Keep-Passion,項目名稱:ImageStitch,代碼行數:11,代碼來源:ImageFusion.py

示例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 
開發者ID:Keep-Passion,項目名稱:ImageStitch,代碼行數:9,代碼來源:ImageFusion.py

示例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) 
開發者ID:PacktPublishing,項目名稱:Practical-Computer-Vision,代碼行數:32,代碼來源:03_pyramid_down_smaple.py


注:本文中的cv2.pyrUp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。