
174 Image Enhancement and Correction
Listing 5 .6: Hu invariant moments of image contours.
1 #!/ usr / bin / env pytho n
2 # Name : ex5_3 .py
3 IMPO RT auxil . auxil as a uxil
4 FROM num py IMPORT *
5 FROM osg eo IMPORT gdal
6 FROM osg eo . g dalconst IMPORT GA_ReadO nly
7 IMPO RT cv2 as cv
8 IMPO RT matplotl ib . pyplot as plt
9
10 DEF main ():
11 gdal . AllR egister ()
12 # read f irst band of an MS image
13 infi le = auxil . select_infile ()
14 IF infile :
15 inDataset = gdal . Open ( infile , GA_R eadOnl y )
16 cols = inDa taset . Ra sterXS ize
17 rows = inDa taset . Ra sterYS ize
18 ELSE :
19 RETURN
20 rast erBand = i nDatas et . GetR asterB and (1)
21 ban