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
# Source: https://scikit-image.org/docs/dev/auto_examples/features_detection/plot_glcm.html | |
import matplotlib.pyplot as plt | |
from skimage.feature import greycomatrix, greycoprops | |
from skimage import data | |
PATCH_SIZE = 21 |
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 | |
from PIL import Image, ImageFilter | |
from matplotlib import pyplot as plt | |
img = Image.open("imgs/chapter5/indoor.jpg") | |
blurred = img.filter(ImageFilter.BLUR) | |
f = plt.figure(figsize=(15,15)) | |
f.add_subplot(1, 2, 1).set_title('Original Image') | |
plt.imshow(img) |
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
# Box blur using OpenCV with normalized kernel => Normal Blur | |
import numpy as np | |
import cv2 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter5/outdoor.jpg", -1) | |
# Used for even float type images | |
blurred_Normalized = np.uint8(cv2.boxFilter(img, cv2.CV_64F, ksize=(5, 5), normalize=True)) |
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 random | |
import cv2 | |
from matplotlib import pyplot as plt | |
from PIL import Image, ImageFilter | |
def sp_noise(image,prob): | |
''' | |
Add salt and pepper noise to image | |
prob: Probability of the noise |
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 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter5/indoor.jpg", 0) | |
kernel = [ | |
[0, 1, 0], | |
[1, -4, 1], | |
[0, 1, 0] | |
] |
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 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter5/sudoku.png", 0) | |
kernel = [ | |
[1, 0, -1], | |
[1, 0, -1], | |
[1, 0, -1] | |
] |
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 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter5/sudoku.png", 0) | |
kernel = [ | |
[1, 1, 1], | |
[0, 0, 0], | |
[-1, -1, -1] |
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 | |
from matplotlib import pyplot as plt | |
img = cv2.imread("imgs/chapter7/hist_eq.jpg", 0) | |
#################################FOCUS########################### | |
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8)) | |
out = clahe.apply(img) | |
################################################################# |
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 | |
from PIL import Image, ImageFilter | |
from matplotlib import pyplot as plt | |
img = Image.open("imgs/chapter7/rain.jpg") | |
####################################FOCUS############################### | |
output = img.filter(ImageFilter.FIND_EDGES); | |
######################################################################## |
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 | |
from PIL import Image, ImageFilter | |
from matplotlib import pyplot as plt | |
img = Image.open("imgs/chapter7/tessellate.png") | |
#######################################FOCUS############################################ | |
output1 = img.filter(ImageFilter.EDGE_ENHANCE) | |
output2 = img.filter(ImageFilter.EDGE_ENHANCE_MORE) | |
######################################################################################## |