Python cv2.pyrUp() Examples
The following are 26
code examples of cv2.pyrUp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example #1
Source File: util.py From DoNotSnap with GNU General Public License v3.0 | 6 votes |
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.
Example #2
Source File: Cartoonlization.py From rabbitVE with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: CVAnalysis.py From DE3-ROB1-CHESS with Creative Commons Attribution 4.0 International | 5 votes |
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--- ]############################### ####################################################################################################
Example #4
Source File: amplify_color.py From Heart-rate-measurement-using-camera with Apache License 2.0 | 5 votes |
def reconstract_from_tensorlist(self,filter_tensor_list,levels=3): final=np.zeros(filter_tensor_list[-1].shape) for i in range(filter_tensor_list[0].shape[0]): up = filter_tensor_list[0][i] for n in range(levels-1): up=cv2.pyrUp(up)+filter_tensor_list[n + 1][i] final[i]=up return final #butterworth bandpass filter
Example #5
Source File: amplify_color.py From Heart-rate-measurement-using-camera with Apache License 2.0 | 5 votes |
def build_laplacian_pyramid(self, src,levels=3): gaussianPyramid = self.build_gaussian_pyramid(src, levels) pyramid=[] for i in range(levels,0,-1): GE=cv2.pyrUp(gaussianPyramid[i]) L=cv2.subtract(gaussianPyramid[i-1],GE) pyramid.append(L) return pyramid #reconstract video from laplacian pyramid
Example #6
Source File: amplify_color.py From Heart-rate-measurement-using-camera with Apache License 2.0 | 5 votes |
def reconstract_video(self,amp_video,origin_video,levels=3): final_video=np.zeros(origin_video.shape) for i in range(0,amp_video.shape[0]): img = amp_video[i] for x in range(levels): img=cv2.pyrUp(img) img=img+origin_video[i] final_video[i]=img return final_video
Example #7
Source File: lappyr.py From PyCV-time with MIT License | 5 votes |
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))
Example #8
Source File: lappyr.py From PyCV-time with MIT License | 5 votes |
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
Example #9
Source File: turing.py From PyCV-time with MIT License | 5 votes |
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
Example #10
Source File: lappyr.py From PyCV-time with MIT License | 5 votes |
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))
Example #11
Source File: lappyr.py From PyCV-time with MIT License | 5 votes |
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
Example #12
Source File: 03_pyramid_down_smaple.py From Practical-Computer-Vision with MIT License | 5 votes |
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)
Example #13
Source File: ImageFusion.py From ImageStitch with MIT License | 5 votes |
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
Example #14
Source File: ImageFusion.py From ImageStitch with MIT License | 5 votes |
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
Example #15
Source File: image_region_analysis.py From DE3-ROB1-CHESS with Creative Commons Attribution 4.0 International | 5 votes |
def show_image (image, title): cv2.imshow (title, cv2.pyrUp(cv2.pyrUp(image)))
Example #16
Source File: lappyr.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
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
Example #17
Source File: CVAnalysis_old.py From DE3-ROB1-CHESS with Creative Commons Attribution 4.0 International | 5 votes |
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--- ]############################### ####################################################################################################
Example #18
Source File: Square.py From DE3-ROB1-CHESS with Creative Commons Attribution 4.0 International | 5 votes |
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)
Example #19
Source File: util.py From SPTM with MIT License | 5 votes |
def double_upsampling(input): return cv2.pyrUp(cv2.pyrUp(input))
Example #20
Source File: Pyramids.py From Finger-Detection-and-Tracking with BSD 2-Clause "Simplified" License | 5 votes |
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()
Example #21
Source File: multi_band_blending.py From dual-fisheye-video-stitching with MIT License | 5 votes |
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
Example #22
Source File: multi_band_blending.py From dual-fisheye-video-stitching with MIT License | 5 votes |
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
Example #23
Source File: blending.py From dual-fisheye-video-stitching with MIT License | 5 votes |
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
Example #24
Source File: blending.py From dual-fisheye-video-stitching with MIT License | 5 votes |
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
Example #25
Source File: turing.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
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
Example #26
Source File: lappyr.py From OpenCV-Python-Tutorial with MIT License | 5 votes |
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))