Instantly share code, notes, and snippets.

# Chongye WangChongyeWang

• Sort options
Created Mar 15, 2019
View comnination_sum2.py
 class Solution(object): def combinationSum2(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ candidates = sorted(candidates) result = [] temp = []
Last active Mar 15, 2019
View comnination_sum.py
 class Solution(object): class Solution(object): def combinationSum(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] """ res = [] temp = []
Created Mar 15, 2019
View permutations.py
 class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result = [] temp = [] self.backtracking(result, temp, nums) return result
Created Mar 15, 2019
View permutations2.py
 class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ nums = sorted(nums) temp = [] result = [] used = [0 for _ in range(len(nums))]
Created Mar 15, 2019
View translations.py
 import cv2 import numpy as np image = cv2.imread('images/input.jpg') # Store height and width of the image height, width = image.shape[:2] quarter_height, quarter_width = height/4, width/4
Created Mar 15, 2019
View rotations.py
 import cv2 import numpy as np image = cv2.imread('images/input.jpg') height, width = image.shape[:2] # Divide by two to rototate the image around its centre rotation_matrix = cv2.getRotationMatrix2D((width/2, height/2), 90, .5) rotated_image = cv2.warpAffine(image, rotation_matrix, (width, height))
Last active Mar 15, 2019
View scaling_re-sizing_interpolations.py
 import cv2 import numpy as np # load our input image image = cv2.imread('images/input.jpg') # Let's make our image 3/4 of it's original size image_scaled = cv2.resize(image, None, fx=0.75, fy=0.75) cv2.imshow('Scaling - Linear Interpolation', image_scaled) cv2.waitKey()
Created Mar 15, 2019
View image_pyramids.py
 import cv2 image = cv2.imread('images/input.jpg') smaller = cv2.pyrDown(image) larger = cv2.pyrUp(smaller) cv2.imshow('Original', image ) cv2.imshow('Smaller ', smaller )
Created Mar 15, 2019
View cropping.py
 import cv2 import numpy as np image = cv2.imread('images/input.jpg') height, width = image.shape[:2] # Let's get the starting pixel coordiantes (top left of cropping rectangle) start_row, start_col = int(height * .25), int(width * .25) # Let's get the ending pixel coordinates (bottom right)
Created Mar 15, 2019
View arithmetic_operations.py
 import cv2 import numpy as np image = cv2.imread('images/input.jpg') # Create a matrix of ones, then multiply it by a scaler of 100 # This gives a matrix with same dimesions of our image with all values being 100 M = np.ones(image.shape, dtype = "uint8") * 175 # We use this to add this matrix M, to our image
You can’t perform that action at this time.