Skip to content

Commit

Permalink
edge detection, image gradient, image pyramids, morphological transfo…
Browse files Browse the repository at this point in the history
…rmations added
  • Loading branch information
isinsuarici committed Jun 29, 2022
1 parent f887a31 commit cd2ae3f
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CannyEdgeDetection/CannyEdgeDetection.py
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)
Binary file added CannyEdgeDetection/edges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Contours/Contours.py
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ı.
24 changes: 24 additions & 0 deletions ImageGradient/ImageGradient.py
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
Binary file added ImageGradient/laplace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImageGradient/sobelx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImageGradient/sobely.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions ImagePyramids/ImagePyramids.py
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.
Binary file added ImagePyramids/high_reso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImagePyramids/lower_lower_reso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImagePyramids/lower_reso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added input_pictures/input_apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added input_pictures/input_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added input_pictures/input_sudoku.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cd2ae3f

Please sign in to comment.