-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edge detection, image gradient, image pyramids, morphological transfo…
…rmations added
- Loading branch information
1 parent
f887a31
commit cd2ae3f
Showing
14 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import cv2 as cv | ||
|
||
""" CANNY EDGE DETECTION **************************************************************** """ | ||
# Öncelikle noise reduction yapılır çünkü canny edge detection, gürültüye karşı duyarlıdır. | ||
# Bu yüzden ilk adımda gauss filtresi ile gürültü kaldırılır. | ||
# Ardından görüntünün intensity gradienti bulunur. | ||
# smoothened image, sobel kerneliyle hem yatay hem dikeyde filtrelenir. | ||
# non-maximum suppression yapılır ardından hysteresis thresholding ? | ||
# opencv tüm bu işlemlerin cv.Canny fonksiyonu ile yapılabilmesini sağlar. | ||
|
||
gray = cv.imread("../input_pictures/input_agac.png", 0) | ||
edges = cv.Canny(gray, 100, 200) # 2.arg=minVal, 3.arg=maxVal | ||
cv.imwrite('edges.png', edges) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import cv2 as cv | ||
|
||
gray = cv.imread("../input_pictures/input_agac.png") | ||
|
||
# Konturlar, aynı renk veya yoğunluğa sahip tüm sürekli noktaları sınır boyunca birleştiren bir eğridir. | ||
# Şekil analizi, nesne algılama, tanımada kullanılır. | ||
# Binary görüntü kullanılırsa daha doğru sonuçlar elde edilir. | ||
# Bu yüzden konturları bulmadan önce threshold veya canny edge detection kullanılır. | ||
# Bulunacak nesne beyaz, arka plan siyah olmalı. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import cv2 as cv | ||
import numpy as np | ||
|
||
|
||
""" IMAGE GRADIENTS **************************************************************** """ | ||
# 1.Sobel and Scharr Derivatives | ||
# SOBEL = gaussian smoothing + differentitation | ||
# bu nedenle gürültüye karşı dayanıklı. | ||
# türev yönü dikey veya yatay olarak belirlenebilir. | ||
# sırasıyla yorder,xorder | ||
# ksize= çekirdeğin boyutu | ||
|
||
img = cv.imread("../input_pictures/input_sudoku.png", 0) | ||
sobelx = cv.Sobel(img, cv.CV_64F, 1, 0, ksize=5) | ||
sobely = cv.Sobel(img, cv.CV_64F, 0, 1, ksize=5) | ||
|
||
cv.imwrite("sobelx.png", sobelx) | ||
cv.imwrite("sobely.png", sobely) | ||
|
||
# 2.Laplacian Derivaties | ||
laplace = cv.Laplacian(img, cv.CV_64F) | ||
cv.imwrite("laplace.png", laplace) | ||
|
||
# ayrıntılı olarak yeniden bak |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import cv2 as cv | ||
|
||
# Normalde sabit boyutlu bir görüntü ile çalışıyorduk. | ||
# Ancak bazı durumlarda aynı görüntünün farklı çözünürlükleriyle çalışmamız gerekir. | ||
# Örneğin, bir görüntüde yüz arıyorsak o görüntüdeki nesnenin hangi boyutta olacağından | ||
# emin olamayız. Bu durumda, aynı görüntüden farklı çözünürlüklerde bir set oluşturup | ||
# hepsinde nesne aramamız gerekir. Bu görüntü kümesine Görüntü Piramitleri denir. | ||
# ( en yüksek çözünürlüklü görüntü altta, en düşük çözünürlüklü görüntü üstte. ) | ||
|
||
""" 1. Gaussian Pyramids *********************************""" | ||
|
||
gray = cv.imread("../input_pictures/input_agac.png") | ||
lower_reso = cv.pyrDown(gray) # level_1 | ||
cv.imwrite("lower_reso.png", lower_reso) | ||
|
||
lower_lower_reso = cv.pyrDown(lower_reso) # level_2 | ||
cv.imwrite("lower_lower_reso.png", lower_lower_reso) | ||
|
||
high_reso = cv.pyrUp(lower_lower_reso) | ||
cv.imwrite("high_reso.png", high_reso) | ||
|
||
# high_reso ile baştaki image aynı değil çünkü çözünürlüğü bir kez düşürdüğümüzde bilgiyi kaybederiz. | ||
|
||
""" 2. Laplace Pyramids *********************************""" | ||
# Laplacian piramitleri, gauss piramitlerinden oluşur. Bunun için özel bir fonksiyon yok. | ||
# Laplacian piramit görüntüleri, yalnızca kenar görüntüleri gibidir. | ||
# Öğelerinin çoğu sıfırdır. | ||
# Görüntü sıkıştırmada kullanılır. | ||
# Laplacian'daki bir seviye, Gauss'daki bu seviye ile Gauss'daki üst | ||
# seviyesinin genişletilmiş versiyonu arasındaki farktan oluşur. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.