Professional Documents
Culture Documents
ipynb - Colaboratory
[[[ 0 29 4]
[ 0 29 4]
[ 0 30 3]
...
[ 35 76 31]
[ 35 76 31]
[ 35 76 31]]
[[ 0 29 4]
[ 0 29 4]
[ 0 31 4]
...
[ 36 77 32]
[ 33 74 29]
[ 31 74 29]]
[[ 0 29 4]
[ 0 30 5]
[ 0 30 5]
...
[ 34 77 34]
[ 28 71 26]
[ 26 72 26]]
...
[[ 86 137 75]
[ 86 137 75]
[ 87 140 77]
...
[ 23 16 1]
[ 28 20 7]
[ 28 20 7]]
[[ 86 137 75]
[ 87 138 76]
[ 88 141 78]
...
[ 27 20 5]
[ 22 14 1]
[ 22 14 1]]
[[ 86 137 75]
[ 87 138 76]
[ 88 141 78]
...
[ 27 20 5]
[ 22 14 1]
[ 22 14 1]]]
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 1/11
6/11/2021 MIDTASK.ipynb - Colaboratory
<matplotlib.image.AxesImage at 0x7f9a69489c90>
[[ 18 18 19 ... 58 58 58]
[ 18 18 19 ... 59 56 56]
[ 18 19 19 ... 59 53 53]
...
[113 113 115 ... 12 17 17]
[113 114 116 ... 16 11 11]
[113 114 116 ... 16 11 11]]
1 plt.imshow(cv2.cvtColor(gray_img, cv2.COLOR_GRAY2RGB))
<matplotlib.image.AxesImage at 0x7f9a69404d10>
[53 73 46]
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 2/11
6/11/2021 MIDTASK.ipynb - Colaboratory
<matplotlib.image.AxesImage at 0x7f9a6837b450>
<matplotlib.image.AxesImage at 0x7f9a682d7f10>
1 piet = cv2.imread('/content/color.jpg')
2 piet_hsv = cv2.cvtColor(piet, cv2.COLOR_BGR2HSV)
1 plt.imshow(cv2.cvtColor(piet, cv2.COLOR_BGR2RGB))
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 3/11
6/11/2021 MIDTASK.ipynb - Colaboratory
<matplotlib.image.AxesImage at 0x7f9a682c9f90>
<matplotlib.image.AxesImage at 0x7f9a6823eed0>
1 upstate = cv2.imread('/content/biru.webp')
2 upstate_hsv =cv2.cvtColor(upstate, cv2.COLOR_BGR2HSV)
3 plt.imshow(cv2.cvtColor(upstate_hsv, cv2.COLOR_HSV2RGB))
<matplotlib.image.AxesImage at 0x7f9a68101c50>
<matplotlib.image.AxesImage at 0x7f9a6945f750>
<matplotlib.image.AxesImage at 0x7f9a68166e90>
1 #GAUSSIAN BLUR
1 img =cv2.imread('/content/city.jpg')
2 plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
<matplotlib.image.AxesImage at 0x7f9a67f85990>
<matplotlib.image.AxesImage at 0x7f9a67efa190>
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 5/11
6/11/2021 MIDTASK.ipynb - Colaboratory
<matplotlib.image.AxesImage at 0x7f9a67e65650>
<matplotlib.image.AxesImage at 0x7f9a67dceb10>
<matplotlib.image.AxesImage at 0x7f9a67dc72d0>
<matplotlib.image.AxesImage at 0x7f9a67d337d0>
1 adaptive_thresh = cv2.adaptiveThreshold(gray_img,255,\
2 cv2 ADAPTIVE THRESH GAUSSIAN C \
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 6/11
6/11/2021 MIDTASK.ipynb - Colaboratory
2 cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
3 cv2.THRESH_BINARY,11,2)
4 plt.imshow(cv2.cvtColor(adaptive_thresh, cv2.COLOR_GRAY2RGB))
<matplotlib.image.AxesImage at 0x7f9a67ca2990>
1 coins = cv2.imread('/content/coin.jpg')
2 plt.imshow(cv2.cvtColor(coins, cv2.COLOR_BGR2RGB))
3 cv2.imwrite('output/coins-orig.jpg', coins)
False
<matplotlib.image.AxesImage at 0x7f9a67834f90>
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 7/11
6/11/2021 MIDTASK.ipynb - Colaboratory
False
1 morph_karnel = np.ones((15,15),np.uint8)
2 coins_morph = cv2.morphologyEx(coins_binary, cv2.MORPH_CLOSE, morph_karnel)
3
4 plt.imshow(cv2.cvtColor(coins_morph, cv2.COLOR_GRAY2RGB))
<matplotlib.image.AxesImage at 0x7f9a67719990>
False
1 bounding_img = np.copy(coins)
2
3
4 for contour in large contours:
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 8/11
6/11/2021 MIDTASK.ipynb - Colaboratory
4 for contour in large_contours:
5 x, y, w, h = cv2.boundingRect(contour)
6 cv2.rectangle(bounding_img, (x, y), (x + w, y + h), (0, 255, 0), 3)
7
8 plt.imshow(cv2.cvtColor(bounding_img, cv2.COLOR_BGR2RGB))
9 cv2.imwrite('output/coins-bounding.jpg', bounding_img)
False
1 #EDGE DETECTIONS
1 cups = cv2.imread('/content/bHszC.jpg')
2 plt.imshow(cv2.cvtColor(cups, cv2.COLOR_BGR2RGB))
3 cv2.imwrite('output/cup-orig.jpg', cups)
False
1 low_thresh = 120
2 high_thresh = 200
3 _, cups_thresh = cv2.threshold(cups_preprocessed, low_thresh, 255, cv2.THRESH_BINARY)
4 plt.imshow(cv2.cvtColor(cups_thresh, cv2.COLOR_GRAY2RGB))
5 cv2.imwrite('ouput/cups-thresh-low.png', cups_thresh)
6
7 _, cups_thresh_hi = cv2.threshold(cups_preprocessed, high_thresh, 255, cv2.THRESH_BINARY)
8 cv2.imwrite('ouput/cups-thresh-hi-.png', cups_thresh_hi)
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 9/11
6/11/2021 MIDTASK.ipynb - Colaboratory
False
False
1 #HOUGH TRANSFORM
False
1s completed at 8:39 AM
https://colab.research.google.com/drive/1GjErfqx20qS5yqUhHdFkSZLTdzeWd7h4#scrollTo=gXrxcbiEpoqH&printMode=true 11/11