Commit 9de7d758 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents ede56b8c 14b64c8e
......@@ -168,6 +168,15 @@ void WMDetTractClustering::updateOutput()
m_clusterOutputID->set( 0, true );
}
m_cluserOC->updateData( boost::shared_ptr< WFiberCluster >( new WFiberCluster( m_clusters[ m_clusterOutputID->get() ] ) ) );
boost::shared_ptr< WDataSetFiberClustering > clustering( new WDataSetFiberClustering() );
for( std::size_t k = 0; k < m_clusters.size(); ++k )
{
clustering->getOrCreateCluster( k )->merge( m_clusters[ k ] );
}
m_clustersOutput->updateData( clustering );
}
void WMDetTractClustering::update()
......@@ -420,6 +429,8 @@ void WMDetTractClustering::connectors()
m_tractIC = WModuleInputData< WDataSetFibers >::createAndAdd( shared_from_this(), "tractInput", "A deterministic tract dataset." );
m_cluserOC = WModuleOutputData< WFiberCluster >::createAndAdd( shared_from_this(), "clusterOutput", "A set of tract indices aka cluster" );
m_clustersOutput = WModuleOutputData< WDataSetFiberClustering >::createAndAdd( shared_from_this(), "allClustersOutput", "The clustering." );
WModule::connectors(); // call WModules initialization
}
......
......@@ -36,6 +36,7 @@
#include "core/common/math/WMatrixSym.h"
#include "core/dataHandler/datastructures/WFiberCluster.h"
#include "core/dataHandler/WDataSetFiberVector.h"
#include "core/dataHandler/WDataSetFiberClustering.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleInputData.h"
......@@ -258,6 +259,11 @@ private:
*/
boost::shared_ptr< WModuleOutputData< WFiberCluster > > m_cluserOC;
/**
* Output connector for all clusters.
*/
boost::shared_ptr< WModuleOutputData< WDataSetFiberClustering > > m_clustersOutput;
/**
* Distance matrix lookUpTable
*/
......
......@@ -15,4 +15,4 @@
#VERSION=1.2.0
#VERSION=1.2.0+hgX -> replaces the X with the current revision number
#VERSUIB=1.2.0+hg1234 -> here, revision number was set by the build scripts for example.
VERSION=0.0.3+hgX
VERSION=0.5.0
......@@ -31,11 +31,12 @@
#include <core/kernel/WModule.h>
#include "buildingsDetection/WMBuildingsDetection.h"
#include "buildingsDetectionByPCA/WMBuildingsDetectionByPCA.h"
#include "treeDetectionByPCA/WMTreeDetectionByPCA.h"
#include "elevationImageExport/WMElevationImageExport.h"
#include "pointGroupsTransform/WMPointGroupsTransform.h"
#include "pointsTransform/WMPointsTransform.h"
#include "pointsCutOutliers/WMPointsCutOutliers.h"
#include "pointsGroupSelector/WMPointsGroupSelector.h"
#include "pointGroupsValidator/WMPointGroupsValidator.h"
#include "readLAS/WMReadLAS.h"
#include "surfaceDetectionByLari/WMSurfaceDetectionByLari.h"
#include "surfaceDetectionByPCL/WMSurfaceDetectionByPCL.h"
......@@ -60,10 +61,11 @@
extern "C" void WLoadModule( WModuleList& m ) // NOLINT
{
m.push_back( boost::shared_ptr< WModule >( new WMBuildingsDetection ) );
m.push_back( boost::shared_ptr< WModule >( new WMBuildingsDetectionByPCA ) );
m.push_back( boost::shared_ptr< WModule >( new WMTreeDetectionByPCA ) );
m.push_back( boost::shared_ptr< WModule >( new WMElevationImageExport ) );
m.push_back( boost::shared_ptr< WModule >( new WMPointGroupsTransform ) );
m.push_back( boost::shared_ptr< WModule >( new WMPointsCutOutliers ) );
m.push_back( boost::shared_ptr< WModule >( new WMPointsGroupSelector ) );
m.push_back( boost::shared_ptr< WModule >( new WMPointGroupsValidator ) );
m.push_back( boost::shared_ptr< WModule >( new WMPointsTransform ) );
m.push_back( boost::shared_ptr< WModule >( new WMReadLAS ) );
m.push_back( boost::shared_ptr< WModule >( new WMSurfaceDetectionByLari ) );
......
......@@ -66,6 +66,7 @@ void WBuildingDetector::detectBuildings( boost::shared_ptr< WDataSetPoints > poi
//targetShowables->setExportElevationImageSettings( -16.0, 8.0 );
//targetShowables->exportElevationImage( "/home/renegade/Dokumente/Projekte/OpenWalnut@Eclipse/elevation images/targetShowables.bmp", 1 );
}
void WBuildingDetector::setDetectionParams( int detailDepth, int minSearchDetailDepth,
double minSearchCutUntilAbove )
{
......@@ -73,10 +74,12 @@ void WBuildingDetector::setDetectionParams( int detailDepth, int minSearchDetail
m_minSearchDetailDepth = pow( 2.0, minSearchDetailDepth );
m_minSearchCutUntilAbove = minSearchCutUntilAbove;
}
WOctree* WBuildingDetector::getBuildingGroups()
{
return m_targetGrouped3d;
}
void WBuildingDetector::initMinimalMaxima( WQuadNode* sourceNode, WQuadTree* targetTree )
{
if ( sourceNode->getRadius() <= m_detailDepth )
......@@ -84,7 +87,7 @@ void WBuildingDetector::initMinimalMaxima( WQuadNode* sourceNode, WQuadTree* tar
double coordX = sourceNode->getCenter( 0 );
double coordY = sourceNode->getCenter( 1 );
double d = m_minSearchDetailDepth / 2.0;
double height = sourceNode->getElevationMax();
double height = sourceNode->getValueMax();
targetTree->registerPoint( coordX - d, coordY - d, height );
targetTree->registerPoint( coordX - d, coordY + d, height );
targetTree->registerPoint( coordX + d, coordY - d, height );
......@@ -97,6 +100,7 @@ void WBuildingDetector::initMinimalMaxima( WQuadNode* sourceNode, WQuadTree* tar
initMinimalMaxima( sourceNode->getChild( child ), targetTree );
}
}
void WBuildingDetector::projectDrawableAreas( WQuadNode* sourceNode,
WQuadTree* minimalMaxima, WQuadTree* targetTree )
{
......@@ -108,11 +112,11 @@ void WBuildingDetector::projectDrawableAreas( WQuadNode* sourceNode,
WQuadNode* minimalNodeBigHeight = minimalMaxima->getLeafNode( coordX, coordY,
m_minSearchCutUntilAboveBigHeights );
if( minimalNode == 0 || minimalNodeBigHeight == 0 ) return;
double minimalHeight = m_minSearchCutUntilAbove + minimalNode->getElevationMin();
double minimalHeightBigHeights = m_minSearchCutUntilAbove + minimalNodeBigHeight->getElevationMin();
if( sourceNode->getElevationMax() < minimalHeight
&& sourceNode->getElevationMax() < minimalHeightBigHeights ) return;
targetTree->registerPoint( coordX, coordY, sourceNode->getElevationMax() );
double minimalHeight = m_minSearchCutUntilAbove + minimalNode->getValueMin();
double minimalHeightBigHeights = m_minSearchCutUntilAbove + minimalNodeBigHeight->getValueMin();
if( sourceNode->getValueMax() < minimalHeight
&& sourceNode->getValueMax() < minimalHeightBigHeights ) return;
targetTree->registerPoint( coordX, coordY, sourceNode->getValueMax() );
}
else
{
......
......@@ -43,10 +43,12 @@ public:
* Constructor of the building detector instance.
*/
explicit WBuildingDetector();
/**
* Destructor of the building detector instance.
*/
virtual ~WBuildingDetector();
/**
* Starts the routine detecting buildings using the point data.
* After executing you can extract the building number from each node
......@@ -54,6 +56,7 @@ public:
* \param points Point data to extract buildings from
*/
void detectBuildings( boost::shared_ptr< WDataSetPoints > points );
/**
* Sets setting params for building recognition
* \param m_detailDepth Data grid resolution of cube group data. The number must
......@@ -68,6 +71,7 @@ public:
*/
void setDetectionParams( int m_detailDepth, int minSearchDetailDepth,
double minSearchCutUntilAbove );
/**
* Returns the 3D node tree. Each leaf node has a group ID number. Many nodes can pe
* pointed by an equal parameter to a single building area.
......@@ -87,6 +91,7 @@ private:
* compare whether points are above threshold.
*/
void initMinimalMaxima( WQuadNode* sourceNode, WQuadTree* targetTree );
/**
* Calculates 2D-areas which cover buildings. Building areas will be outlined in targetTree.
* \param sourceImage Input image. Maximal point values are taken.
......@@ -96,6 +101,7 @@ private:
*/
void projectDrawableAreas( WQuadNode* sourceImage, WQuadTree* minimalMaxima,
WQuadTree* targetTree );
/**
* It generates a voxel structure. Leaf nodes should appear where building points exist.
* \param sourceNode Source octree contatining data that represents any
......@@ -107,26 +113,31 @@ private:
void fetchBuildingVoxels( WOctNode* sourceNode, WQuadTree* buildingPixels,
WOctree* targetTree );
/**
* Resolution of input/output data in meters. Use only numbers depictable by 2^n
* where n can also be 0 or below.
*/
double m_detailDepth;
/**
* Resolution of the relative minimum search image. Use only numbers depictable by 2^n
* where n can also be 0 or below. The bigger the pixels the greater are the areas
* searched from an examined X/Y area. Their radius equals that parameter.
*/
double m_minSearchDetailDepth;
/**
* Height that must exceed above an relative minimum to recognize it as a building pixel.
*/
double m_minSearchCutUntilAbove;
/**
* The same as m_minSearchDetailDepth. But it's used to still be able tu use smaller
* m_minSearchDetailDepth values not having big proglems with larger buildings.
*/
double m_detailDepthBigHeights;
/**
* The corresponding threshold height setting for m_detailDepthBigHeights.
*/
......
......@@ -67,6 +67,7 @@ const char** WMBuildingsDetection::getXPMIcon() const
{
return WMBuildingsDetection_xpm;
}
const std::string WMBuildingsDetection::getName() const
{
return "Buildings Detection";
......@@ -107,7 +108,7 @@ void WMBuildingsDetection::properties()
"depth for the octree search tree.", 0 );
m_detailDepth->setMin( -3 );
m_detailDepth->setMax( 4 );
m_detailDepthLabel = m_properties->addProperty( "Voxel width meters: ", "Resulting detail depth "
m_detailDepthLabel = m_properties->addProperty( "Pixel width meters: ", "Resulting detail depth "
"in meters for the octree search tree.", pow( 2.0, m_detailDepth->get() ) * 2.0 );
m_detailDepthLabel->setPurpose( PV_PURPOSE_INFORMATION );
......@@ -196,6 +197,14 @@ void WMBuildingsDetection::moduleMain()
outputGroups->push_back( buildingVoxel->getGroupNr() );
}
}
if( outputVerts->size() == 0)
{
for( size_t dimension = 0; dimension < 3; dimension++ )
outputVerts->push_back( 0.0 );
for( size_t colorChannel = 0; colorChannel < 3; colorChannel++ )
outputColors->push_back( 0.0 );
outputGroups->push_back( 0 );
}
boost::shared_ptr< WDataSetPointsGrouped > output(
new WDataSetPointsGrouped( outputVerts, outputColors, outputGroups ) );
m_outputPointsGrouped->updateData( output );
......@@ -205,8 +214,8 @@ void WMBuildingsDetection::moduleMain()
m_xMax->set( boundingBox->getRootNode()->getXMax() );
m_yMin->set( boundingBox->getRootNode()->getYMin() );
m_yMax->set( boundingBox->getRootNode()->getYMax() );
m_zMin->set( boundingBox->getRootNode()->getElevationMin() );
m_zMax->set( boundingBox->getRootNode()->getElevationMax() );
m_zMin->set( boundingBox->getRootNode()->getValueMin() );
m_zMax->set( boundingBox->getRootNode()->getValueMax() );
m_progressStatus->finish();
}
m_reloadData->set( WPVBaseTypes::PV_TRIGGER_READY, true );
......@@ -230,6 +239,7 @@ void WMBuildingsDetection::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
void WMBuildingsDetection::setProgressSettings( size_t steps )
{
m_progress->removeSubProgress( m_progressStatus );
......
......@@ -169,26 +169,32 @@ private:
* Info tab property: Input points count.
*/
WPropInt m_nbPoints;
/**
* Info tab property: Minimal x value of input x coordunates.
*/
WPropDouble m_xMin;
/**
* Info tab property: Maximal x value of input x coordunates.
*/
WPropDouble m_xMax;
/**
* Info tab property: Minimal y value of input x coordunates.
*/
WPropDouble m_yMin;
/**
* Info tab property: Maximal y value of input x coordunates.
*/
WPropDouble m_yMax;
/**
* Info tab property: Minimal z value of input x coordunates.
*/
WPropDouble m_zMin;
/**
* Info tab property: Maximal z value of input x coordunates.
*/
......@@ -199,11 +205,13 @@ private:
* radius equals to its result.
*/
WPropInt m_detailDepth;
/**
* Determines the resolution of smallest octree nodes. Their radius equal that value.
*/
WPropDouble m_detailDepthLabel;
WPropTrigger m_reloadData; //!< This property triggers the actual reading,
......@@ -216,6 +224,7 @@ private:
* four is below of the height threshold of the examinable point.
*/
WPropInt m_minSearchDetailDepth;
/**
* Main building detection setting.
* Height that must exceed above an relative minimum to recognize it as a building pixel.
......
......@@ -38,14 +38,17 @@ WBmpImage::~WBmpImage()
{
resizeImage( 0, 0 );
}
size_t WBmpImage::getSizeX()
{
return m_sizeX;
}
size_t WBmpImage::getSizeY()
{
return m_sizeY;
}
void WBmpImage::resizeImage( size_t sizeX, size_t sizeY )
{
m_sizeX = sizeX;
......@@ -64,30 +67,36 @@ void WBmpImage::resizeImage( size_t sizeX, size_t sizeY )
m_dataB[index] = 0;
}
}
size_t WBmpImage::getR( size_t x, size_t y )
{
if( x >= m_sizeX || y >= m_sizeY ) return 0;
return m_dataR[getIndex( x, y )];
}
size_t WBmpImage::getG( size_t x, size_t y )
{
if( x >= m_sizeX || y >= m_sizeY ) return 0;
return m_dataG[getIndex( x, y )];
}
size_t WBmpImage::getB( size_t x, size_t y )
{
if( x >= m_sizeX || y >= m_sizeY ) return 0;
return m_dataB[getIndex( x, y )];
}
size_t WBmpImage::getA( size_t x, size_t y )
{
if( x >= m_sizeX || y >= m_sizeY ) return 0;
return 255;
}
void WBmpImage::setPixel( size_t x, size_t y, size_t intensity )
{
setPixel( x, y, intensity, intensity, intensity );
}
void WBmpImage::setPixel( size_t x, size_t y, size_t r, size_t g, size_t b )
{
if( x >= m_sizeX || y >= m_sizeY ) return;
......@@ -96,6 +105,7 @@ void WBmpImage::setPixel( size_t x, size_t y, size_t r, size_t g, size_t b )
m_dataG[index] = g < 256 ?g :255;
m_dataB[index] = b < 256 ?b :255;
}
size_t WBmpImage::getIndex( size_t x, size_t y )
{
return x + m_sizeX * y;
......@@ -121,7 +131,7 @@ void WBmpImage::importElevationImageDrawNode( WQuadNode* node, WQuadTree* quadTr
if( node->getRadius() <= quadTree->getDetailLevel() )
{
int intensity = ( ( elevImageMode != 0
?node->getElevationMax() :node->getElevationMin() )
?node->getValueMax() :node->getValueMin() )
- m_minElevImageZ ) * m_intensityIncreasesPerMeter;
if(elevImageMode == 2) intensity = node->getPointCount();
if( intensity < 0 ) intensity = 0;
......@@ -137,6 +147,7 @@ void WBmpImage::importElevationImageDrawNode( WQuadNode* node, WQuadTree* quadTr
importElevationImageDrawNode( node->getChild( child ), quadTree, elevImageMode );
}
}
void WBmpImage::setExportElevationImageSettings( double minElevImageZ, double intensityIncreasesPerMeter )
{
m_minElevImageZ = minElevImageZ;
......
......@@ -28,10 +28,10 @@
#include <vector>
#include "../../common/datastructures/quadtree/WQuadNode.h"
#include "../../common/datastructures/quadtree/WQuadTree.h"
#include "../../common/datastructures/octree/WOctree.h"
#include "../../common/datastructures/WDataSetPointsGrouped.h"
#include "../../datastructures/quadtree/WQuadNode.h"
#include "../../datastructures/quadtree/WQuadTree.h"
#include "../../datastructures/octree/WOctree.h"
#include "../../datastructures/WDataSetPointsGrouped.h"
/**
* Image object. Currently it's used for saving bmp files.
......@@ -45,26 +45,31 @@ public:
* \param sizeY Image height.
*/
WBmpImage( size_t sizeX, size_t sizeY );
/**
* Image container destructor.
*/
virtual ~WBmpImage();
/**
* Returns the image width.
* \return The image width.
*/
size_t getSizeX();
/**
* Returns the image height.
* \return The image height.
*/
size_t getSizeY();
/**
* Resizes and clears the image.
* \param sizeX Image width.
* \param sizeY Image height.
*/
void resizeImage( size_t sizeX, size_t sizeY );
/**
* Returns the red color value of a pixel.
* \param x Pixel index on X axis (0 to width-1).
......@@ -72,6 +77,7 @@ public:
* \return The red color value (0 to 255).
*/
size_t getR( size_t x, size_t y );
/**
* Returns the green color value of a pixel.
* \param x Pixel index on X axis (0 to width-1).
......@@ -79,6 +85,7 @@ public:
* \return The green color value (0 to 255).
*/
size_t getG( size_t x, size_t y );
/**
* Returns the blue color value of a pixel.
* \param x Pixel index on X axis (0 to width-1).
......@@ -86,6 +93,7 @@ public:
* \return The blue color value (0 to 255).
*/
size_t getB( size_t x, size_t y );
/**
* Returns the opacity value of a pixel.
* \param x Pixel index on X axis (0 to width-1).
......@@ -93,6 +101,7 @@ public:
* \return The opacity value (0 to 255).
*/
size_t getA( size_t x, size_t y );
/**
* Sets a color within a pixel using just an intensity.
* \param x Pixel index on X axis (0 to width-1).
......@@ -100,6 +109,7 @@ public:
* \param intensity Value that will be put to all color values equally (0 to 255).
*/
void setPixel( size_t x, size_t y, size_t intensity );
/**
* Sets a color within a pixel.
* \param x Pixel index on X axis (0 to width-1).
......@@ -121,6 +131,7 @@ public:
* 2: Point count each X/Y bin coordinate.
*/
void importElevationImage( WQuadTree* quadTree, size_t elevImageMode );
/**
* Sets the elevation image export settings.
* \param minElevImageZ The elevation height that is mapped to the black color.
......@@ -150,20 +161,24 @@ private:
* Image width.
*/
size_t m_sizeX;
/**
* Image height.
*/
size_t m_sizeY;
/**
* Image red color intensity data. The order corresponds to the following pixel traversing.
* It traverses linewise each starting at Y=0 from first to last X value.
*/
std::vector<size_t> m_dataR;
/**
* Image green color intensity data. The order corresponds to the following pixel traversing.
* It traverses linewise each starting at Y=0 from first to last X value.
*/
std::vector<size_t> m_dataG;
/**
* Image blue color intensity data. The order corresponds to the following pixel traversing.
* It traverses linewise each starting at Y=0 from first to last X value.
......@@ -175,11 +190,13 @@ private:
* The elevation height that is mapped to the black color.
*/
double m_minElevImageZ;
/**
* Elevation image export setting.
* Intensity increase count per meter.
*/
double m_intensityIncreasesPerMeter;
/**
* Draws a quadtree leaf node to the bmp file. All subchildren will also be drawn.
* \param node Quadtree node to draw
......
......@@ -96,8 +96,8 @@ void WBmpSaver::saveImage( WBmpImage* image, const char* path )
info[26] = (unsigned char)( sizeData>>16 );
info[27] = (unsigned char)( sizeData>>24 );
stream.write( ( char* )file, sizeof( file ) );
stream.write( ( char* )info, sizeof( info ) );
stream.write( reinterpret_cast<char*>( file ), sizeof( file ) );
stream.write( reinterpret_cast<char*>( info ), sizeof( info ) );
unsigned char pad[3] = {0, 0, 0};
......@@ -110,9 +110,9 @@ void WBmpSaver::saveImage( WBmpImage* image, const char* path )
pixel[1] = image->getG( x, y );
pixel[2] = image->getR( x, y );
stream.write( ( char* )pixel, 3 );
stream.write( reinterpret_cast<char*>( pixel ), 3 );
}
stream.write( ( char* )( pad ), padSize );
stream.write( reinterpret_cast<char*>( pad ), padSize );
}
stream.close();
}
......@@ -42,10 +42,12 @@ public:
* Bmp image saver constructor
*/
WBmpSaver();
/**
* Bmp image saver destructor
*/
virtual ~WBmpSaver();
/**
* Static method to save an image as a bmp file.
* \param image The image to store.
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <iostream>
#include "WGroupEdit.h"
WGroupEdit::WGroupEdit()
{
m_mergeGroups = false;
}
WGroupEdit::~WGroupEdit()
{
}
void WGroupEdit::initProocessBegin()