Skip to content

Commit e289415

Browse files
committedFeb 27, 2016
[processing] new Fusion algs: ImageCreate and IntensityImage
1 parent 1c585a1 commit e289415

File tree

3 files changed

+181
-1
lines changed

3 files changed

+181
-1
lines changed
 

‎python/plugins/processing/algs/lidar/LidarToolsAlgorithmProvider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
from fusion.MergeData import MergeData
132132
from fusion.FilterData import FilterData
133133
from fusion.PolyClipData import PolyClipData
134+
from fusion.ImageCreate import ImageCreate
135+
from fusion.IntensityImage import IntensityImage
134136
from fusion.FusionUtils import FusionUtils
135137

136138

@@ -201,7 +203,8 @@ def _loadAlgorithms(self):
201203
Catalog(), CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(),
202204
Csv2Grid(), Cover(), FilterData(), GridMetrics(), GroundFilter(),
203205
GridSurfaceCreate(), MergeData(), TinSurfaceCreate(), PolyClipData(),
204-
DTM2TIF(), DTM2ASCII(), FirstLastReturn(), ASCII2DTM()
206+
DTM2TIF(), DTM2ASCII(), FirstLastReturn(), ASCII2DTM(), ImageCreate(),
207+
IntensityImage()
205208
]
206209
for alg in fusiontools:
207210
alg.group, alg.i18n_group = alg.trAlgorithm('Fusion')
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
ImageCreate.py
6+
---------------------
7+
Date : January 2016
8+
Copyright : (C) 2016 by Niccolo' Marchi
9+
Email : sciurusurbanus at hotmail dot it
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = "Niccolo' Marchi"
21+
__date__ = 'January 2016'
22+
__copyright__ = "(C) 2016 by Niccolo' Marchi"
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import os
29+
from processing.core.parameters import ParameterBoolean
30+
from processing.core.parameters import ParameterFile
31+
from processing.core.parameters import ParameterSelection
32+
from processing.core.parameters import ParameterNumber
33+
from processing.core.outputs import OutputFile
34+
from FusionAlgorithm import FusionAlgorithm
35+
from FusionUtils import FusionUtils
36+
37+
38+
class ImageCreate(FusionAlgorithm):
39+
40+
INPUT = 'INPUT'
41+
COLOROPTION = 'COLOROPTION'
42+
GROUND = 'GROUND'
43+
PIXEL = 'PIXEL'
44+
RGB = 'RGB'
45+
SWITCH = 'SWITCH'
46+
OUTPUT = 'OUTPUT'
47+
48+
49+
def defineCharacteristics(self):
50+
self.name, self.i18n_name = self.trAlgorithm('ImageCreate')
51+
self.group, self.i18n_group = self.trAlgorithm('Points')
52+
self.addParameter(ParameterFile(
53+
self.INPUT, self.tr('Input LAS')))
54+
self.addParameter(ParameterSelection(
55+
self.COLOROPTION, self.tr('Method to assign colour'), ['Intensity', 'Elevation','Height']))
56+
self.addParameter(ParameterFile(
57+
self.GROUND, self.tr("Ground file (used with 'Height' method)"),'dtm'))
58+
self.addParameter(ParameterBoolean(self.RGB,
59+
self.tr('Use RGB colour model to create the colour ramp'), False))
60+
self.addParameter(ParameterNumber(
61+
self.PIXEL, self.tr('Pixel size'), 0, None, 1.0))
62+
self.addParameter(ParameterSelection(
63+
self.SWITCH, self.tr('Output format'), ['JPEG', 'Bitmap']))
64+
self.addOutput(OutputFile(self.OUTPUT, 'Output image'))
65+
self.addAdvancedModifiers()
66+
67+
def processAlgorithm(self, progress):
68+
commands = [os.path.join(FusionUtils.FusionPath(), 'ImageCreate.exe')]
69+
commands.append('/verbose')
70+
commands.append('/coloroption:' + unicode(self.getParameterValue(self.COLOROPTION)))
71+
ground = self.getParameterValue(self.GROUND)
72+
if unicode(ground).strip():
73+
commands.append('/dtm:' + unicode(ground))
74+
if self.getParameterValue(self.RGB):
75+
commands.append('/rgb')
76+
if self.getParameterValue(self.SWITCH) == 0:
77+
commands.append('/jpg')
78+
else:
79+
commands.append('/bmp')
80+
outFile = self.getOutputValue(self.OUTPUT)
81+
commands.append(outFile)
82+
commands.append(unicode(self.getParameterValue(self.PIXEL)))
83+
files = self.getParameterValue(self.INPUT).split(';')
84+
if len(files) == 1:
85+
commands.append(self.getParameterValue(self.INPUT))
86+
else:
87+
FusionUtils.createFileList(files)
88+
commands.append(FusionUtils.tempFileListFilepath())
89+
FusionUtils.runFusion(commands, progress)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
IntensityImage.py
6+
---------------------
7+
Date : January 2016
8+
Copyright : (C) 2016 by Niccolo' Marchi
9+
Email : sciurusurbanus at hotmail dot it
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = "Niccolo' Marchi"
21+
__date__ = 'January 2016'
22+
__copyright__ = "(C) 2016 by Niccolo' Marchi"
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import os
29+
from processing.core.parameters import ParameterBoolean
30+
from processing.core.parameters import ParameterFile
31+
from processing.core.parameters import ParameterSelection
32+
from processing.core.parameters import ParameterNumber
33+
from processing.core.outputs import OutputFile
34+
from FusionAlgorithm import FusionAlgorithm
35+
from FusionUtils import FusionUtils
36+
37+
38+
class IntensityImage(FusionAlgorithm):
39+
40+
INPUT = 'INPUT'
41+
ALLRET = 'ALLRET'
42+
LOWEST = 'LOWEST'
43+
HIST = 'HIST'
44+
PIXEL ='PIXEL'
45+
SWITCH = 'SWITCH'
46+
OUTPUT = 'OUTPUT'
47+
48+
49+
def defineCharacteristics(self):
50+
self.name, self.i18n_name = self.trAlgorithm('IntensityImage')
51+
self.group, self.i18n_group = self.trAlgorithm('Points')
52+
self.addParameter(ParameterFile(
53+
self.INPUT, self.tr('Input file')))
54+
55+
self.addParameter(ParameterBoolean(self.ALLRET,
56+
self.tr('Use all returns instead of only first'), False))
57+
self.addParameter(ParameterBoolean(self.LOWEST,
58+
self.tr('Use the lowest return in pixel area to assign the intensity value'), False))
59+
self.addParameter(ParameterBoolean(self.HIST,
60+
self.tr('Produce a CSV intensity histogram data file'), False))
61+
self.addParameter(ParameterNumber(
62+
self.PIXEL, self.tr('Pixel size'), 0, None, 1.0))
63+
self.addParameter(ParameterSelection(
64+
self.SWITCH, self.tr('Output format'), ['Bitmap', 'JPEG']))
65+
self.addOutput(OutputFile(self.OUTPUT, 'Output image'))
66+
self.addAdvancedModifiers()
67+
68+
def processAlgorithm(self, progress):
69+
commands = [os.path.join(FusionUtils.FusionPath(), 'IntensityImage.exe')]
70+
commands.append('/verbose')
71+
if self.getParameterValue(self.ALLRET):
72+
commands.append('/allreturns')
73+
if self.getParameterValue(self.LOWEST):
74+
commands.append('/lowest')
75+
if self.getParameterValue(self.HIST):
76+
commands.append('/hist')
77+
if self.getParameterValue(self.SWITCH) == 1:
78+
commands.append('/jpg')
79+
commands.append(unicode(self.getParameterValue(self.PIXEL)))
80+
outFile = self.getOutputValue(self.OUTPUT)
81+
commands.append(outFile)
82+
files = self.getParameterValue(self.INPUT).split(';')
83+
if len(files) == 1:
84+
commands.append(self.getParameterValue(self.INPUT))
85+
else:
86+
FusionUtils.createFileList(files)
87+
commands.append(FusionUtils.tempFileListFilepath())
88+
FusionUtils.runFusion(commands, progress)

0 commit comments

Comments
 (0)
Please sign in to comment.