option to chose steepest slope, code cleaning
This commit is contained in:
+2
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <qG3PointDialog.h>
|
||||
#include <G3PointDialog.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
CCCoreLib::DgmOctree::NearestNeighboursSearchStruct m_nNSS;
|
||||
ccMainAppInterface *m_app;
|
||||
Eigen::ArrayXi m_stack;
|
||||
qG3PointDialog* m_dlg;
|
||||
G3PointDialog* m_dlg;
|
||||
|
||||
static G3PointAction* s_g3PointAction;
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
target_sources( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/ActionA.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3PointPlugin.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/qG3PointDialog.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3Point.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3PointDialog.h
|
||||
)
|
||||
|
||||
target_include_directories( ${PROJECT_NAME}
|
||||
|
||||
@@ -7,15 +7,16 @@ namespace Ui {
|
||||
class qG3PointDialog;
|
||||
}
|
||||
|
||||
class qG3PointDialog : public QDialog
|
||||
class G3PointDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit qG3PointDialog(QWidget *parent = nullptr);
|
||||
~qG3PointDialog();
|
||||
explicit G3PointDialog(QWidget *parent = nullptr);
|
||||
~G3PointDialog();
|
||||
void emitRun();
|
||||
int getkNN();
|
||||
bool isSteepestSlope();
|
||||
|
||||
signals:
|
||||
void run();
|
||||
+51
-26
@@ -19,7 +19,7 @@
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
||||
#include <qG3PointDialog.h>
|
||||
#include <G3PointDialog.h>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace G3Point
|
||||
@@ -302,37 +302,70 @@ void G3PointAction::add_to_stack_braun_willett(int index, const Eigen::ArrayXi&
|
||||
|
||||
int G3PointAction::segment_labels_braun_willett(bool useParallelStrategy)
|
||||
{
|
||||
std::cout << "[segment_labels_braun_willett]" << std::endl;
|
||||
// for each point, find in the neighborhood the point with the minimum slope (the receiver)
|
||||
Eigen::ArrayXd min_slopes(m_neighbors_slopes.rowwise().minCoeff());
|
||||
Eigen::ArrayXi index_of_min_slope = Eigen::ArrayXi::Zero(m_cloud->size());
|
||||
std::cout << "[segment_labels]" << std::endl;
|
||||
|
||||
bool steepestSlope = m_dlg->isSteepestSlope();
|
||||
|
||||
// for each point, find in the neighborhood the point with the extreme slope, depending on the mode (the receiver)
|
||||
Eigen::ArrayXd extreme_slopes;
|
||||
if (steepestSlope)
|
||||
{
|
||||
std::cout << "[segment_labels] classical steepest slope algorithm [Braun, Willett 2013]" << std::endl;
|
||||
extreme_slopes = m_neighbors_slopes.rowwise().maxCoeff();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "[segment_labels] reversed version of the steepest slope algorithm [Braun, Willett 2013]" << std::endl;
|
||||
extreme_slopes = m_neighbors_slopes.rowwise().minCoeff();
|
||||
}
|
||||
Eigen::ArrayXi index_of_extreme_slope = Eigen::ArrayXi::Zero(m_cloud->size());
|
||||
Eigen::ArrayXi receivers(m_cloud->size());
|
||||
|
||||
for (unsigned index = 0; index < m_cloud->size(); index++)
|
||||
{
|
||||
double min_slope = min_slopes(index);
|
||||
double extreme_slope = extreme_slopes(index);
|
||||
for (int k = 0; k < m_kNN; k++)
|
||||
{
|
||||
if (m_neighbors_slopes(index, k) == min_slope)
|
||||
if (m_neighbors_slopes(index, k) == extreme_slope)
|
||||
{
|
||||
index_of_min_slope(index) = k;
|
||||
index_of_extreme_slope(index) = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
receivers(index) = m_neighbors_indexes(index, index_of_min_slope(index));
|
||||
receivers(index) = m_neighbors_indexes(index, index_of_extreme_slope(index));
|
||||
}
|
||||
|
||||
// if the minimum slope is positive, the receiver is a local maximum
|
||||
int nb_maxima = (min_slopes > 0).count();
|
||||
int nb_maxima;
|
||||
if (steepestSlope)
|
||||
{
|
||||
nb_maxima = (extreme_slopes < 0).count();
|
||||
}
|
||||
else
|
||||
{
|
||||
nb_maxima = (extreme_slopes > 0).count();
|
||||
}
|
||||
Eigen::ArrayXi localMaximumIndexes = Eigen::ArrayXi::Zero(nb_maxima);
|
||||
int l = 0;
|
||||
for (unsigned int k = 0; k < m_cloud->size(); k++)
|
||||
{
|
||||
if (min_slopes(k) > 0)
|
||||
if (steepestSlope)
|
||||
{
|
||||
localMaximumIndexes(l) = k;
|
||||
receivers(k) = k;
|
||||
l++;
|
||||
if (extreme_slopes(k) < 0)
|
||||
{
|
||||
localMaximumIndexes(l) = k;
|
||||
receivers(k) = k;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (extreme_slopes(k) > 0)
|
||||
{
|
||||
localMaximumIndexes(l) = k;
|
||||
receivers(k) = k;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,15 +466,7 @@ int G3PointAction::segment_labels_braun_willett(bool useParallelStrategy)
|
||||
m_cloud->showSF(false);
|
||||
|
||||
m_cloud->redrawDisplay();
|
||||
// m_cloud->prepareDisplayForRefresh();
|
||||
|
||||
// ccHObject::Container selectedEntities;
|
||||
// selectedEntities.push_back(cloud);
|
||||
|
||||
// if (!sfConvertToRandomRGB(selectedEntities, m_app->getMainWindow()))
|
||||
// {
|
||||
// ccLog::Error("[G3Point::segment_labels] impossible to convert g3point_label to RGB colors");
|
||||
// }
|
||||
m_cloud->prepareDisplayForRefresh();
|
||||
|
||||
if (m_app)
|
||||
{
|
||||
@@ -688,8 +713,8 @@ void G3PointAction::run()
|
||||
query_neighbors(m_cloud, m_app, true);
|
||||
|
||||
// Perform initial segmentation
|
||||
// int nLabels = segment_labels();
|
||||
int nLabels = segment_labels_braun_willett();
|
||||
|
||||
// int nLabels = segment_labels_steepest_slope();
|
||||
|
||||
m_app->dispToConsole( "[G3Point] initial segmentation: " + QString::number(nLabels) + " labels", ccMainAppInterface::STD_CONSOLE_MESSAGE );
|
||||
@@ -733,12 +758,12 @@ void G3PointAction::createAction(ccMainAppInterface *appInterface)
|
||||
|
||||
s_g3PointAction->m_app = appInterface;
|
||||
//display dialog
|
||||
s_g3PointAction->m_dlg = new qG3PointDialog();
|
||||
s_g3PointAction->m_dlg = new G3PointDialog();
|
||||
s_g3PointAction->m_dlg->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
s_g3PointAction->m_dlg->setWindowFlag(Qt::WindowStaysOnTopHint, true);
|
||||
s_g3PointAction->m_dlg->setWindowTitle("G3Point");
|
||||
|
||||
connect(s_g3PointAction->m_dlg, &qG3PointDialog::run, s_g3PointAction, &G3PointAction::run);
|
||||
connect(s_g3PointAction->m_dlg, &G3PointDialog::run, s_g3PointAction, &G3PointAction::run);
|
||||
s_g3PointAction->m_cloud = ccHObjectCaster::ToPointCloud(ent);
|
||||
s_g3PointAction->m_dlg->show();
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,6 +2,6 @@
|
||||
target_sources( ${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/ActionA.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3PointPlugin.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/qG3PointDialog.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3Point.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/G3PointDialog.cpp
|
||||
)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "G3PointPlugin.h"
|
||||
#include "G3Point.h"
|
||||
|
||||
#include "ActionA.h"
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "G3PointDialog.h"
|
||||
#include "ui_qG3PointDialog.h"
|
||||
|
||||
G3PointDialog::G3PointDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::qG3PointDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(this->ui->pushButtonSegment, &QPushButton::clicked, this, &G3PointDialog::emitRun);
|
||||
}
|
||||
|
||||
G3PointDialog::~G3PointDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void G3PointDialog::emitRun()
|
||||
{
|
||||
emit run();
|
||||
}
|
||||
|
||||
int G3PointDialog::getkNN()
|
||||
{
|
||||
return this->ui->spinBoxkNN->value();
|
||||
}
|
||||
|
||||
bool G3PointDialog::isSteepestSlope()
|
||||
{
|
||||
return this->ui->radioButtonSteepestSlope->isChecked();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "qG3PointDialog.h"
|
||||
#include "ui_qG3PointDialog.h"
|
||||
|
||||
qG3PointDialog::qG3PointDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::qG3PointDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(this->ui->pushButtonSegment, &QPushButton::clicked, this, &qG3PointDialog::emitRun);
|
||||
}
|
||||
|
||||
qG3PointDialog::~qG3PointDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void qG3PointDialog::emitRun()
|
||||
{
|
||||
emit run();
|
||||
}
|
||||
|
||||
int qG3PointDialog::getkNN()
|
||||
{
|
||||
return this->ui->spinBoxkNN->value();
|
||||
}
|
||||
+22
-5
@@ -6,14 +6,21 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>157</width>
|
||||
<height>73</height>
|
||||
<width>190</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButtonSegment">
|
||||
<property name="text">
|
||||
<string>Segment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@@ -34,10 +41,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButtonSegment">
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="radioButtonSteepestSlope">
|
||||
<property name="text">
|
||||
<string>Segment</string>
|
||||
<string>steepest slope</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="radioButtonG3Point">
|
||||
<property name="text">
|
||||
<string>G3Point</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user