Professional Documents
Culture Documents
In [101]:
# Buat daftar untuk menyimpan url gambar
urls = ["https://i.pinimg.com/564x/c4/66/65/c46665e47cf56642a598f1a0040bae8f.jpg"
]
# loop terhadap URL gambar, Anda dapat menyimpan beberapa url gambar dalam daftar
In [102]:
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 1/14
4/30/2021 temp-161977272719037728
In [103]:
color = ('b','g','r')
for i,col in enumerate(color):
histr = cv.calcHist([image],[i],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.show()
In [104]:
gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
cv_imshow(gray_image)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 2/14
4/30/2021 temp-161977272719037728
In [105]:
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 3/14
4/30/2021 temp-161977272719037728
In [106]:
# myGrayImg = cv.cvtColor(myImg, cv.COLOR_BGR2GRAY)
# cv_imshow()
In [107]:
plt.contour(gray_image, origin = "image")
Out[108]:
thresh = cv.threshold(gray_image,100,200,0)
contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
cv.drawContours(image, contours, -1, (0, 255, 0), 3) plt.imshow(image)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 4/14
4/30/2021 temp-161977272719037728
Out[109]:
<matplotlib.image.AxesImage at 0x7f1053576050>
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 5/14
4/30/2021 temp-161977272719037728
In [108]:
im2 = 255 - gray_image
cv_imshow(im2)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 6/14
4/30/2021 temp-161977272719037728
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 7/14
4/30/2021 temp-161977272719037728
In [109]:
im3 = (100.0/255)*gray_image + 100
cv_imshow(im3)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 8/14
4/30/2021 temp-161977272719037728
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 9/14
4/30/2021 temp-161977272719037728
In [112]:
im4 = 255.0*(gray_image/255.0)**2
cv_imshow(im4)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 10/14
4/30/2021 temp-161977272719037728
In [113]:
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 11/14
4/30/2021 temp-161977272719037728
In [114]:
im5 = histeq(im4)
cv_imshow(im5)
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 12/14
4/30/2021 temp-161977272719037728
In [115]:
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 13/14
4/30/2021 temp-161977272719037728
https://htmtopdf.herokuapp.com/ipynbviewer/temp/ae2c470261d80ebb8b9038df8b6b30c3/Untitled3.html?t=1619772733026 14/14