-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleaner_float.py
72 lines (47 loc) · 1.58 KB
/
Cleaner_float.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys,os,string,math,string,time
from osgeo import gdal, ogr
import numpy as np
import argparse
import subprocess
from f_ReadImage import*
from f_WriteImage import*
from f_WriteLabelImage import*
import matplotlib.pyplot as plt
import argparse
import subprocess
#======================== PARSER ====================================
parser = argparse.ArgumentParser(description='Remplacer valeur d une image en fonction d une valeur d une autre')
parser.add_argument('-ref','--inputRef',help='Input ref image')
parser.add_argument('-v','--Value',help='Input ref value')
parser.add_argument('-im','--inputImg',help='Input image to clean')
parser.add_argument('-o','--outputValue',help='output value')
parser.add_argument('-out','--outputImage',help='output Image')
args = parser.parse_args()
params = vars(args)
if params['inputImg'] is None:
parser.print_help()
sys.exit(1)
mask_path = params['inputRef']
novalue = int(params['Value'])
img_path = params['inputImg']
outvalue = int(params['outputValue'])
outname = params['outputImage']
#===================== TRAITEMENT ====================================
print '----- Work in progress -----'
#================ LECTURE RASTER et INFOS=============================
img = ReadImage(mask_path)
train = ReadImage(img_path)
x = img.shape[0]
y = img.shape[1]
print(x)
print(y)
print(train.shape)
train=train.reshape(x*y)
img = img.reshape(x*y)
indexes = np.where(img==novalue)
train[indexes]=outvalue
train = train.reshape(x,y)
WriteImage( outname, train,mask_path )
print '----- Job Done ! -----'