Skip to content
Snippets Groups Projects
Commit f86e86ed authored by Sacha Percot-Tétu's avatar Sacha Percot-Tétu
Browse files

Added the Hough operation

parent 819f69e9
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include "HoughDialog.h"
#include "ui_HoughDialog.h"
HoughDialog::HoughDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::HoughDialog)
{
ui->setupUi(this);
}
HoughDialog::~HoughDialog()
{
delete ui;
}
bool HoughDialog::isMethod1() const {
return ui->method1Button->isChecked();
}
double HoughDialog::getAngleStep() const {
return ui->angleBox->value();
}
double HoughDialog::getDistanceStep() const {
return ui->distanceBox->value();
}
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HOUGHDIALOG_H
#define HOUGHDIALOG_H
#include <QDialog>
namespace Ui {
class HoughDialog;
}
class HoughDialog : public QDialog
{
Q_OBJECT
public:
explicit HoughDialog(QWidget *parent = 0);
~HoughDialog();
bool isMethod1() const;
double getAngleStep() const;
double getDistanceStep() const;
private:
Ui::HoughDialog *ui;
};
#endif // HOUGHDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HoughDialog</class>
<widget class="QDialog" name="HoughDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>259</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Method</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="method1Button">
<property name="text">
<string>Method #1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="method2Button">
<property name="text">
<string>Method #2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="angleLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Angle step : </string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="angleBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="distanceLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Distance step : </string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="distanceBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>512.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>HoughDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>HoughDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>method2Button</sender>
<signal>toggled(bool)</signal>
<receiver>angleLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>92</x>
<y>87</y>
</hint>
</hints>
</connection>
<connection>
<sender>method2Button</sender>
<signal>toggled(bool)</signal>
<receiver>angleBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
<y>87</y>
</hint>
</hints>
</connection>
<connection>
<sender>method2Button</sender>
<signal>toggled(bool)</signal>
<receiver>distanceLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>96</x>
<y>123</y>
</hint>
</hints>
</connection>
<connection>
<sender>method2Button</sender>
<signal>toggled(bool)</signal>
<receiver>distanceBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
<y>123</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include "HoughOp.h"
#include <QApplication>
#include "Transforms.h"
#include <Converter.h>
#include <GrayscaleImage.h>
#include "HoughDialog.h"
using namespace std;
using namespace imagein;
HoughOp::HoughOp() : Operation(qApp->translate("Operations", "Hough transform").toStdString())
{
}
bool HoughOp::needCurrentImg() const {
return true;
}
void HoughOp::operator()(const imagein::Image* img, const std::map<const imagein::Image*, std::string>&) {
HoughDialog* dialog = new HoughDialog(QApplication::activeWindow());
QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec());
Image_t<double>* resImg;
if(code!=QDialog::Accepted) return;
if(dialog->isMethod1()) {
GrayscaleImage* image = Converter<GrayscaleImage>::convert(*img);
resImg = Transforms::hough(image);
delete image;
}
else {
resImg = Transforms::hough2(img, dialog->getAngleStep(), dialog->getDistanceStep());
}
outDoubleImage(resImg, qApp->translate("Hough", "Hough transform").toStdString(), true, true);
// Image* resImg2;
// Transforms::hough2_inverse(resImg, &resImg2, 512, 0.);
// outImage(resImg2, qApp->translate("Hough", "Hough inverse transform").toStdString());
}
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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 3 of the License, or
* (at your option) any later version.
*
* EIImage 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HOUGHOP_H
#define HOUGHOP_H
#include <Operation.h>
class HoughOp : public Operation
{
public:
HoughOp();
void operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&);
bool needCurrentImg() const;
};
#endif // HOUGHOP_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment