Skip to content

Instantly share code, notes, and snippets.

View ChongyeWang's full-sized avatar

Chongye Wang ChongyeWang

View GitHub Profile
class Solution(object):
class Solution(object):
def combinationSum(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
res = []
temp = []
class Solution(object):
def combinationSum2(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
candidates = sorted(candidates)
result = []
temp = []
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
result = []
temp = []
self.backtracking(result, temp, nums)
return result
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))]
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
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))
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()
import cv2
image = cv2.imread('images/input.jpg')
smaller = cv2.pyrDown(image)
larger = cv2.pyrUp(smaller)
cv2.imshow('Original', image )
cv2.imshow('Smaller ', smaller )
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)
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