This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def combinationSum2(self, candidates, target): | |
""" | |
:type candidates: List[int] | |
:type target: int | |
:rtype: List[List[int]] | |
""" | |
candidates = sorted(candidates) | |
result = [] | |
temp = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
class Solution(object): | |
def combinationSum(self, candidates, target): | |
""" | |
:type candidates: List[int] | |
:type target: int | |
:rtype: List[List[int]] | |
""" | |
res = [] | |
temp = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution(object): | |
def permute(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: List[List[int]] | |
""" | |
result = [] | |
temp = [] | |
self.backtracking(result, temp, nums) | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
image = cv2.imread('images/input.jpg') | |
smaller = cv2.pyrDown(image) | |
larger = cv2.pyrUp(smaller) | |
cv2.imshow('Original', image ) | |
cv2.imshow('Smaller ', smaller ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer