-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_smoothing_params.py
53 lines (37 loc) · 1.53 KB
/
test_smoothing_params.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
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from uavClassification import *
from tqdm import tqdm
import itertools
inputImg = "../input/test_image_cubic_resample.tif"
RGBImg, RGBprofile = readRaster(inputImg)
radio = range(2, 18, 2)
spatial = range(2, 18, 2)
combs = itertools.product(spatial, radio)
smoothout = "../output/smooth/smoothed.tif" # "../smooth/smooth_" + run
MeanShiftSmoothing(inputImg, smoothout, "../output/smooth_position.tif")
for a,b in tqdm(list(combs)):
#print(str(a) + "|" + str(b))
run = str(a) + "_" + str(b) + ".tif"
segmentedout = "../output/segmented/segmented_" + run
#segmentedout = "../output/segmented_direct/segmented_" + run
classifiedout = "../output/classified/class_" + run
#classifiedout = "../output/classified_direct/class" + run
#print("segmentation")
MeanShiftSegmentation(smoothout, segmentedout, spatialr = a, ranger = b)
segmentImg, segprofile = readRaster(segmentedout)
ids, stats = segmentStats(segmentImg, RGBImg)
classified = segmentClustering(stats, 6, segmentImg, ids)
writeRaster(classifiedout, classified, segprofile)
#######################
#testing classification
#######################
#segmented = "../segmented.tif"
#segmentImg, segprofile = readRaster(segmented)
#RGBImg, RGBprofile = readRaster(inputImg)
#print("calculate stats")
#ids, stats = segmentStats(segmentImg, RGBImg)
#print("main script")
#print("classify")
#classified = segmentClustering(stats, 5, segmentImg, ids)
#print("write raster")
#writeRaster("../classified.tif", classified, segprofile)