-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.py
37 lines (25 loc) · 1.07 KB
/
script.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
# -*- coding: utf-8 -*-
from uavClassification import *
#fname = "test_image_cubic_resample"
fname = "orthofoto_small_cubic_resample"
inputImg = "../input/" + fname + ".tif"
stretchedImg = "../input/" + fname + "_stretched.tif"
RGBImg, RGBprofile = readRaster(inputImg)
stretched = stretchHistogram(RGBImg)
writeRaster(stretchedImg, stretched, RGBprofile)
MeanShiftSmoothing(stretchedImg, "../output/smooth/smooth_out.tif", "../output/smooth_position.tif")
print("segmentation")
MeanShiftSegmentation("../output/smooth/smooth_out.tif", "../output/segmented/segmented.tif", spatialr = 16, ranger = 10)
#######################
#testing classification
#######################
segmented = "../output/segmented/segmented.tif"
segmentImg, segprofile = readRaster(segmented)
RGBImg, RGBprofile = readRaster(stretchedImg)
print("calculate stats")
ids, stats = segmentStats(segmentImg, RGBImg)
print("main script")
print("classify")
classified = segmentClustering(stats, 5, segmentImg, ids)
print("write raster")
writeRaster("../output/classified/classified.tif", classified, segprofile)