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 numpy as np | |
import cv2 as opencv | |
# Read Image | |
image = opencv.imread('einstein.PNG', opencv.IMREAD_GRAYSCALE) | |
fifth_percentile = np.percentile(image, 5) # 5th percentile- used as min value | |
nintyfive_percentile = np.percentile(image, 95) # used for max value | |
output = np.zeros([image.shape[0], image.shape[1]], dtype=np.uint8) | |
# pixel value less than 5th percentile -- set to 0 | |
# pixel value > 95th percentile -- set to 255 |
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 numpy as np | |
import cv2 as opencv | |
import Transforms | |
import od as o | |
import cca | |
import pad as p | |
import csv | |
import os | |
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
def maxFilter(img, size): | |
out = np.zeros([img.shape[0], img.shape[1]], dtype="int") | |
for i in range(img.shape[0] - size): | |
for j in range(img.shape[1] - size): | |
mat = img[i: i + size, j: j + size] | |
mat = np.ravel(mat) # convert to 1D array | |
mat = np.sort(mat) | |
out[i, j] = np.max(mat) | |
return out |
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 numpy as np | |
import cv2 as opencv | |
import random as r | |
def neighbours(i, j, src): | |
# left | |
left = src[i, j - 1] | |
# top | |
top = src[i - 1, j] |