-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzernike.py
43 lines (34 loc) · 1.09 KB
/
zernike.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 19 18:34:02 2018
@author: Abhishek
"""
import mahotas
import cv2
from watershed_using_scipi import Wsegment
from centreOfMass import com
import imutils
import matplotlib.pyplot as plt
import scipy as sp
def Zernike(image):
(_cm,_radius)=com(image)
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
moments=mahotas.features.zernike_moments(gray,radius=_radius,cm=_cm)
return moments
#Previous changes and ideas
"""
Watershed will make zernike moments invariant to scaling and transformation
zernike moments are inherently invariant to rotation(But better to use Gray Scale)
#watershed of gray image
#wshed_img=Wsegment(gray_img)
#plt.imshow(wshed_img,cmap='nipy_spectral')
#plt.show()
#inverting the image and finding OTSU threshold
_,thresh = cv2.threshold(gray_img,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
#auto_canny
edged = imutils.auto_canny(gray_img)
#plt.imshow(edged)
#Finding contours in an image
(_, cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
"""