import cv2 as cv
import numpy as np
PATH = 'resources/Photos/cats.jpg'
img = cv.imread(PATH)
cv.imshow('Cat', img)
blank1 = np.zeros((img.shape[0], img.shape[1]), dtype='uint8')
cv.imshow('Blank1', blank1)
blank = np.zeros(img.shape, dtype='uint8')
cv.imshow('Blank', blank)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
canny = cv.Canny(img, 125, 175)
cv.imshow('Canny Cats', canny)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_NONE)
print(f'{len(contours)} contour(s) found!')
blur = cv.GaussianBlur(gray, (5, 5), cv.BORDER_DEFAULT)
cv.imshow('Blur', blur)
canny_blur = cv.Canny(blur, 125, 175)
cv.imshow('Canny Cats blur', canny_blur)
contours, hierarchies = cv.findContours(canny_blur, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
ret, thresh = cv.threshold(gray, 125, 255, cv.THRESH_BINARY)
cv.imshow('Thresh', thresh)
canny_thresh = cv.Canny(thresh, 125, 175)
cv.imshow('Canny thresh', canny_thresh)
contours, hierarchies = cv.findContours(thresh, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
cv.waitKey(0)

ca18e95df2d71e33880f786fc2400ac37529dc48
<mask token>

<mask token>
cv.imshow('Cat', img)
<mask token>
cv.imshow('Blank1', blank1)
<mask token>
cv.imshow('Blank', blank)
<mask token>
cv.imshow('Gray', gray)
<mask token>
cv.imshow('Canny Cats', canny)
<mask token>
print(f'{len(contours)} contour(s) found!')
<mask token>
print(f'{len(contours)} contour(s) found!')
<mask token>
cv.imshow('Blur', blur)
<mask token>
cv.imshow('Canny Cats blur', canny_blur)
<mask token>
print(f'{len(contours)} contour(s) found!')
<mask token>
cv.imshow('Thresh', thresh)
<mask token>
cv.imshow('Canny thresh', canny_thresh)
<mask token>
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
<mask token>
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
cv.waitKey(0)

<mask token>
PATH = 'resources/Photos/cats.jpg'
img = cv.imread(PATH)
cv.imshow('Cat', img)
blank1 = np.zeros((img.shape[0], img.shape[1]), dtype='uint8')
cv.imshow('Blank1', blank1)
blank = np.zeros(img.shape, dtype='uint8')
cv.imshow('Blank', blank)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
canny = cv.Canny(img, 125, 175)
cv.imshow('Canny Cats', canny)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_NONE)
print(f'{len(contours)} contour(s) found!')
blur = cv.GaussianBlur(gray, (5, 5), cv.BORDER_DEFAULT)
cv.imshow('Blur', blur)
canny_blur = cv.Canny(blur, 125, 175)
cv.imshow('Canny Cats blur', canny_blur)
contours, hierarchies = cv.findContours(canny_blur, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
ret, thresh = cv.threshold(gray, 125, 255, cv.THRESH_BINARY)
cv.imshow('Thresh', thresh)
canny_thresh = cv.Canny(thresh, 125, 175)
cv.imshow('Canny thresh', canny_thresh)
contours, hierarchies = cv.findContours(thresh, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
cv.waitKey(0)

import cv2 as cv
import numpy as np
PATH = 'resources/Photos/cats.jpg'
img = cv.imread(PATH)
cv.imshow('Cat', img)
blank1 = np.zeros((img.shape[0], img.shape[1]), dtype='uint8')
cv.imshow('Blank1', blank1)
blank = np.zeros(img.shape, dtype='uint8')
cv.imshow('Blank', blank)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
canny = cv.Canny(img, 125, 175)
cv.imshow('Canny Cats', canny)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_NONE)
print(f'{len(contours)} contour(s) found!')
blur = cv.GaussianBlur(gray, (5, 5), cv.BORDER_DEFAULT)
cv.imshow('Blur', blur)
canny_blur = cv.Canny(blur, 125, 175)
cv.imshow('Canny Cats blur', canny_blur)
contours, hierarchies = cv.findContours(canny_blur, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
ret, thresh = cv.threshold(gray, 125, 255, cv.THRESH_BINARY)
cv.imshow('Thresh', thresh)
canny_thresh = cv.Canny(thresh, 125, 175)
cv.imshow('Canny thresh', canny_thresh)
contours, hierarchies = cv.findContours(thresh, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
contours, hierarchies = cv.findContours(canny, cv.RETR_LIST, cv.
    CHAIN_APPROX_SIMPLE)
print(f'{len(contours)} contour(s) found!')
cv.drawContours(blank, contours, -1, (0, 0, 225), 1)
cv.imshow('Contours Drawn', blank)
cv.waitKey(0)
