Skip to content
Snippets Groups Projects
Commit a4168f64 authored by Bigot Quentin's avatar Bigot Quentin
Browse files

add possibility to choose the width and the height of the resut image for inverse Hough transform

parent 0d9609b4
No related branches found
No related tags found
No related merge requests found
...@@ -32,8 +32,12 @@ InverseHoughDialog::~InverseHoughDialog() ...@@ -32,8 +32,12 @@ InverseHoughDialog::~InverseHoughDialog()
delete ui; delete ui;
} }
int InverseHoughDialog::getSize() const { int InverseHoughDialog::getWidth() const {
return ui->sizeBox->value(); return ui->widthBox->value();
}
int InverseHoughDialog::getHeight() const {
return ui->heightBox->value();
} }
int InverseHoughDialog::getThreshodl() const { int InverseHoughDialog::getThreshodl() const {
......
...@@ -33,7 +33,8 @@ class InverseHoughDialog : public QDialog ...@@ -33,7 +33,8 @@ class InverseHoughDialog : public QDialog
public: public:
explicit InverseHoughDialog(QWidget *parent = 0); explicit InverseHoughDialog(QWidget *parent = 0);
~InverseHoughDialog(); ~InverseHoughDialog();
int getSize() const; int getWidth() const;
int getHeight() const;
int getThreshodl() const; int getThreshodl() const;
private: private:
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Reconstructed image size : </string> <string>Reconstructed image width : </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="sizeBox"> <widget class="QSpinBox" name="widthBox">
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
...@@ -32,27 +32,47 @@ ...@@ -32,27 +32,47 @@
<number>65536</number> <number>65536</number>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<number>128</number> <number>1</number>
</property> </property>
<property name="value"> <property name="value">
<number>256</number> <number>256</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Reconstruction threshold : </string> <string>Reconstruction threshold : </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="thresholdBox"> <widget class="QSpinBox" name="thresholdBox">
<property name="maximum"> <property name="maximum">
<number>65536</number> <number>65536</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Reconstructed image height :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="heightBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>65536</number>
</property>
<property name="value">
<number>256</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
......
...@@ -40,6 +40,6 @@ void InverseHoughOp::operator()(const imagein::Image_t<double>* img, const std:: ...@@ -40,6 +40,6 @@ void InverseHoughOp::operator()(const imagein::Image_t<double>* img, const std::
if(code!=QDialog::Accepted) return; if(code!=QDialog::Accepted) return;
Image* resImg2; Image* resImg2;
Transforms::hough2_inverse(img, &resImg2, dialog->getSize(), dialog->getThreshodl()); Transforms::hough2_inverse(img, &resImg2, dialog->getWidth(), dialog->getHeight(), dialog->getThreshodl());
outImage(resImg2, qApp->translate("Hough", "Hough inverse transform").toStdString()); outImage(resImg2, qApp->translate("Hough", "Hough inverse transform").toStdString());
} }
...@@ -181,9 +181,9 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double ...@@ -181,9 +181,9 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
return resImg; return resImg;
} }
string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgptr, unsigned int size, unsigned int threshold) { string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgptr, unsigned int width, unsigned int height, unsigned int threshold) {
Image_t<uint32_t>* resImg = new Image_t<uint32_t>(size, size, image->getNbChannels(), uint32_t(0)); Image_t<uint32_t>* resImg = new Image_t<uint32_t>(width, height, image->getNbChannels(), uint32_t(0));
// int param = 5000 + 20 * image->getWidth() * image->getHeight(); // int param = 5000 + 20 * image->getWidth() * image->getHeight();
...@@ -203,15 +203,15 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt ...@@ -203,15 +203,15 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
int cmpt = 0; int cmpt = 0;
for(unsigned int c = 0; c < image->getNbChannels(); ++c) { for(unsigned int c = 0; c < image->getNbChannels(); ++c) {
for(unsigned int j = 0; j < image->getHeight(); ++j) { for(unsigned int i = 0; i < image->getHeight(); ++i) {
for(unsigned int i = 0; i < image->getWidth(); ++i) { for(unsigned int j = 0; j < image->getWidth(); ++j) {
int n = image->getPixelAt(i, j, c); int n = image->getPixelAt(j, i, c);
if(n >= threshold) if(n >= threshold)
{ {
cmpt++; cmpt++;
double angle = angleStep * j / 180. * pi; double angle = angleStep * i / 180. * pi;
double rho = rhoStep * i; double rho = rhoStep * j;
double sinte = sin(angle); double sinte = sin(angle);
double coste = cos(angle); double coste = cos(angle);
...@@ -219,19 +219,19 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt ...@@ -219,19 +219,19 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
// strcat( buffer, tampon); // strcat( buffer, tampon);
//Construction de la droite d'quation //Construction de la droite d'quation
for(unsigned int jj = 0; jj < size; ++jj) { for(unsigned int jj = 0; jj < width; ++jj) {
// int kk = rho * (cos(angle) + tan(angle) * sin(angle)) - tan(angle)*jj; // int kk = rho * (cos(angle) + tan(angle) * sin(angle)) - tan(angle)*jj;
int kk = (rho - sinte * jj) / coste; int kk = (rho - sinte * jj) / coste;
if( kk > 0 && kk < size) { if( kk > 0 && kk < height) {
resImg->pixelAt(kk, jj, c) += n; resImg->pixelAt(jj, kk, c) += n;
} }
} }
for(unsigned int ii = 0; ii < size; ++ii) { for(unsigned int ii = 0; ii < height; ++ii) {
// int kk = ( rho * (cos(angle) + tan(angle) * sin(angle)) -ii ) / tan(angle); // int kk = ( rho * (cos(angle) + tan(angle) * sin(angle)) -ii ) / tan(angle);
int kk = (rho - coste * ii) / sinte; int kk = (rho - coste * ii) / sinte;
if( kk>0 && kk < size) { if( kk>0 && kk < width) {
resImg->pixelAt(ii, kk, c) += n; resImg->pixelAt(kk, ii, c) += n;
} }
} }
......
...@@ -28,7 +28,7 @@ namespace Transforms ...@@ -28,7 +28,7 @@ namespace Transforms
{ {
imagein::Image_t<double> *hough( const imagein::GrayscaleImage *im ); // This function works imagein::Image_t<double> *hough( const imagein::GrayscaleImage *im ); // This function works
imagein::Image_t<double> *hough2( const imagein::Image *im , double angleStep, double rhoStep); // This function works imagein::Image_t<double> *hough2( const imagein::Image *im , double angleStep, double rhoStep); // This function works
std::string hough2_inverse(const imagein::Image_t<double> *image, imagein::Image **resImg, unsigned int size, unsigned int threshold); std::string hough2_inverse(const imagein::Image_t<double> *image, imagein::Image **resImg, unsigned int width, unsigned int height, unsigned int threshold);
std::string Hadamard( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL); std::string Hadamard( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL);
std::string Haar( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL ); std::string Haar( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL );
std::string cosinus( const imagein::Image *image, imagein::Image_t<double> **resImg, imagein::Image **invImg, imagein::GrayscaleImage_t<bool> *selection = NULL ); std::string cosinus( const imagein::Image *image, imagein::Image_t<double> **resImg, imagein::Image **invImg, imagein::GrayscaleImage_t<bool> *selection = NULL );
......
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