Skip to content

Commit

Permalink
[processing] new Fusion algs: ImageCreate and IntensityImage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Feb 27, 2016
1 parent 1c585a1 commit e289415
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
from fusion.MergeData import MergeData
from fusion.FilterData import FilterData
from fusion.PolyClipData import PolyClipData
from fusion.ImageCreate import ImageCreate
from fusion.IntensityImage import IntensityImage
from fusion.FusionUtils import FusionUtils


Expand Down Expand Up @@ -201,7 +203,8 @@ def _loadAlgorithms(self):
Catalog(), CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(),
Csv2Grid(), Cover(), FilterData(), GridMetrics(), GroundFilter(),
GridSurfaceCreate(), MergeData(), TinSurfaceCreate(), PolyClipData(),
DTM2TIF(), DTM2ASCII(), FirstLastReturn(), ASCII2DTM()
DTM2TIF(), DTM2ASCII(), FirstLastReturn(), ASCII2DTM(), ImageCreate(),
IntensityImage()
]
for alg in fusiontools:
alg.group, alg.i18n_group = alg.trAlgorithm('Fusion')
Expand Down
89 changes: 89 additions & 0 deletions python/plugins/processing/algs/lidar/fusion/ImageCreate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
ImageCreate.py
---------------------
Date : January 2016
Copyright : (C) 2016 by Niccolo' Marchi
Email : sciurusurbanus at hotmail dot it
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = "Niccolo' Marchi"
__date__ = 'January 2016'
__copyright__ = "(C) 2016 by Niccolo' Marchi"

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'

import os
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterFile
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterNumber
from processing.core.outputs import OutputFile
from FusionAlgorithm import FusionAlgorithm
from FusionUtils import FusionUtils


class ImageCreate(FusionAlgorithm):

INPUT = 'INPUT'
COLOROPTION = 'COLOROPTION'
GROUND = 'GROUND'
PIXEL = 'PIXEL'
RGB = 'RGB'
SWITCH = 'SWITCH'
OUTPUT = 'OUTPUT'


def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('ImageCreate')
self.group, self.i18n_group = self.trAlgorithm('Points')
self.addParameter(ParameterFile(
self.INPUT, self.tr('Input LAS')))
self.addParameter(ParameterSelection(
self.COLOROPTION, self.tr('Method to assign colour'), ['Intensity', 'Elevation','Height']))
self.addParameter(ParameterFile(
self.GROUND, self.tr("Ground file (used with 'Height' method)"),'dtm'))
self.addParameter(ParameterBoolean(self.RGB,
self.tr('Use RGB colour model to create the colour ramp'), False))
self.addParameter(ParameterNumber(
self.PIXEL, self.tr('Pixel size'), 0, None, 1.0))
self.addParameter(ParameterSelection(
self.SWITCH, self.tr('Output format'), ['JPEG', 'Bitmap']))
self.addOutput(OutputFile(self.OUTPUT, 'Output image'))
self.addAdvancedModifiers()

def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), 'ImageCreate.exe')]
commands.append('/verbose')
commands.append('/coloroption:' + unicode(self.getParameterValue(self.COLOROPTION)))
ground = self.getParameterValue(self.GROUND)
if unicode(ground).strip():
commands.append('/dtm:' + unicode(ground))
if self.getParameterValue(self.RGB):
commands.append('/rgb')
if self.getParameterValue(self.SWITCH) == 0:
commands.append('/jpg')
else:
commands.append('/bmp')
outFile = self.getOutputValue(self.OUTPUT)
commands.append(outFile)
commands.append(unicode(self.getParameterValue(self.PIXEL)))
files = self.getParameterValue(self.INPUT).split(';')
if len(files) == 1:
commands.append(self.getParameterValue(self.INPUT))
else:
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())
FusionUtils.runFusion(commands, progress)
88 changes: 88 additions & 0 deletions python/plugins/processing/algs/lidar/fusion/IntensityImage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
IntensityImage.py
---------------------
Date : January 2016
Copyright : (C) 2016 by Niccolo' Marchi
Email : sciurusurbanus at hotmail dot it
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = "Niccolo' Marchi"
__date__ = 'January 2016'
__copyright__ = "(C) 2016 by Niccolo' Marchi"

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'

import os
from processing.core.parameters import ParameterBoolean
from processing.core.parameters import ParameterFile
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterNumber
from processing.core.outputs import OutputFile
from FusionAlgorithm import FusionAlgorithm
from FusionUtils import FusionUtils


class IntensityImage(FusionAlgorithm):

INPUT = 'INPUT'
ALLRET = 'ALLRET'
LOWEST = 'LOWEST'
HIST = 'HIST'
PIXEL ='PIXEL'
SWITCH = 'SWITCH'
OUTPUT = 'OUTPUT'


def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('IntensityImage')
self.group, self.i18n_group = self.trAlgorithm('Points')
self.addParameter(ParameterFile(
self.INPUT, self.tr('Input file')))

self.addParameter(ParameterBoolean(self.ALLRET,
self.tr('Use all returns instead of only first'), False))
self.addParameter(ParameterBoolean(self.LOWEST,
self.tr('Use the lowest return in pixel area to assign the intensity value'), False))
self.addParameter(ParameterBoolean(self.HIST,
self.tr('Produce a CSV intensity histogram data file'), False))
self.addParameter(ParameterNumber(
self.PIXEL, self.tr('Pixel size'), 0, None, 1.0))
self.addParameter(ParameterSelection(
self.SWITCH, self.tr('Output format'), ['Bitmap', 'JPEG']))
self.addOutput(OutputFile(self.OUTPUT, 'Output image'))
self.addAdvancedModifiers()

def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), 'IntensityImage.exe')]
commands.append('/verbose')
if self.getParameterValue(self.ALLRET):
commands.append('/allreturns')
if self.getParameterValue(self.LOWEST):
commands.append('/lowest')
if self.getParameterValue(self.HIST):
commands.append('/hist')
if self.getParameterValue(self.SWITCH) == 1:
commands.append('/jpg')
commands.append(unicode(self.getParameterValue(self.PIXEL)))
outFile = self.getOutputValue(self.OUTPUT)
commands.append(outFile)
files = self.getParameterValue(self.INPUT).split(';')
if len(files) == 1:
commands.append(self.getParameterValue(self.INPUT))
else:
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())
FusionUtils.runFusion(commands, progress)

0 comments on commit e289415

Please sign in to comment.