# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import cv2
import matplotlib.pyplot as plt

# load image
img = cv2.imread('images/sunflower.jpg')

# +
# # copy image
img_copy = img.copy()

# convert to rgb 
img_rgb = cv2.cvtColor(img_copy, cv2.COLOR_BGR2RGB)
# show image
plt.imshow(img_rgb)
# -

# ### convert to Grayscale

gray = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2GRAY)
#show image
plt.imshow(gray, cmap='gray')

# ## Implement Canny Edge Detection

# +
#set lower and upper
lower = 120
upper = 240

# create canny 
edges = cv2.Canny(gray, lower, upper)

# show image
plt.imshow(edges, cmap='gray')


# +
wide   =  cv2.Canny(gray, 30, 100) 
tight  =  cv2.Canny(gray, 180, 240)

f, (ax1, ax2) = plt.subplots(1, 2, figsize=(20,10))
ax1.set_title('wide'),ax1.imshow(wide, cmap='gray')
ax2.set_title('tight'),ax2.imshow(tight, cmap='gray')
# -



StarcoderdataJupyterScriptsDedupFiltered