This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
# Perform erosion operations on the binary image | |
for i in range(1, 6): | |
# Parameter as None means that we apply default kernel | |
# (3,3) 8-neighborhood rectangle kernel. | |
eroded = cv2.erode(gray.copy(), None, iterations=i) | |
cv2.imshow(f'Eroded: {i} times', eroded) | |
# Wait for the key press to move further. |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
# Perform Dilation operation | |
for i in range(1, 6): | |
# Parameter as None means that we apply default kernel | |
# (3,3) 8-neighborhood rectangle kernel. | |
dilated = cv2.dilate(gray.copy(), None, iterations=i) | |
cv2.imshow(f"Dilated: {i} times", dilated) | |
cv2.waitKey(0) |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
# Perform Opening: Erosion followed by Dilation. | |
kernel_sizes = [(3, 3), (5, 5), (7, 7)] | |
for kernel_size in kernel_sizes: | |
# Get 8-neighborhood kernel based on the kernel size | |
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, kernel_size) | |
# Apply kernel to the grayscale binary image | |
opened = cv2.morphologyEx(gray.copy(), cv2.MORPH_OPEN, kernel) | |
# Display "Opened" image |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
kernel_sizes = [(3, 3), (5, 5), (7, 7)] | |
# Perform Closing: Dilation followed by Erosion. | |
for kernel_size in kernel_sizes: | |
# Get 8-neighborhood kernel based on the kernel size | |
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, kernel_size) | |
# Apply kernel to the grayscale binary image | |
closed = cv2.morphologyEx(gray.copy(), cv2.MORPH_CLOSE, kernel) |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
kernel_sizes = [(3, 3), (5, 5), (7, 7)] | |
# Perform Morpholigical_gradient: Difference between Dilation and Erosion | |
for kernel_size in kernel_sizes: | |
# Get 8-neighborhood kernel based on the kernel size | |
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, kernel_size) | |
# Apply kernel to the grayscale binary image | |
grad = cv2.morphologyEx(gray.copy(), cv2.MORPH_GRADIENT, kernel) |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
# kernel defined. The size of kernel is based on the problem statement. | |
# Following kernel is for revealing License plate region in the image. | |
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (20, 5)) | |
# Perform TopHat: Difference between grayscale image and opening. This will give bright foreground over dark background | |
top_hat = cv2.morphologyEx(gray.copy(), cv2.MORPH_TOPHAT, kernel) | |
# Display output after TopHat operation | |
cv2.imshow("TopHat", top_hat) |
This file contains hidden or 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
# gray is the numpy array of grayscale of binary image. | |
# kernel defined. The size of kernel is based on the problem statement. | |
# Following kernel is for revealing License plate region in the image. | |
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (20, 5)) | |
# Perform BlackHat: Difference between grayscale image and closing. This will give dark foreground over light background | |
black_hat = cv2.morphologyEx(gray.copy(), cv2.MORPH_BLACKHAT, kernel) | |
# Display output after BlackHat operation | |
cv2.imshow("BlackHat", black_hat) |
This file contains hidden or 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
python3 -m venv {env_name} | |
source {env_name}/bin/activate | |
python3 -m pip install requests bs4 pandas |
This file contains hidden or 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 datetime | |
import requests | |
from bs4 import BeautifulSoup | |
import pandas as pd |
This file contains hidden or 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
response = requests.get('https://www.nytimes.com/interactive/2017/06/23/opinion/trumps-lies.html') |
OlderNewer