diff --git a/app/Operations/InverseHoughDialog.cpp b/app/Operations/InverseHoughDialog.cpp index 5f81105b6fdf3403c488c3ea2ad1d6f4819e506c..76a339f381aaa59e008c783aa69ba5facdd2325e 100644 --- a/app/Operations/InverseHoughDialog.cpp +++ b/app/Operations/InverseHoughDialog.cpp @@ -32,8 +32,12 @@ InverseHoughDialog::~InverseHoughDialog() delete ui; } -int InverseHoughDialog::getSize() const { - return ui->sizeBox->value(); +int InverseHoughDialog::getWidth() const { + return ui->widthBox->value(); +} + +int InverseHoughDialog::getHeight() const { + return ui->heightBox->value(); } int InverseHoughDialog::getThreshodl() const { diff --git a/app/Operations/InverseHoughDialog.h b/app/Operations/InverseHoughDialog.h index 8e1cbeea1d303bab0121471f11c1a5d0e812a35d..405cb4ccde775c96bdba4703efa1c399c073e84e 100644 --- a/app/Operations/InverseHoughDialog.h +++ b/app/Operations/InverseHoughDialog.h @@ -33,7 +33,8 @@ class InverseHoughDialog : public QDialog public: explicit InverseHoughDialog(QWidget *parent = 0); ~InverseHoughDialog(); - int getSize() const; + int getWidth() const; + int getHeight() const; int getThreshodl() const; private: diff --git a/app/Operations/InverseHoughDialog.ui b/app/Operations/InverseHoughDialog.ui index 08a3cce3b4b4fc193dd651f7f0e103ff5583bc04..fd0b42b7ae404ea7d5d3b13d8e546775554fad65 100644 --- a/app/Operations/InverseHoughDialog.ui +++ b/app/Operations/InverseHoughDialog.ui @@ -19,12 +19,12 @@ <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> - <string>Reconstructed image size : </string> + <string>Reconstructed image width : </string> </property> </widget> </item> <item row="0" column="1"> - <widget class="QSpinBox" name="sizeBox"> + <widget class="QSpinBox" name="widthBox"> <property name="minimum"> <number>1</number> </property> @@ -32,27 +32,47 @@ <number>65536</number> </property> <property name="singleStep"> - <number>128</number> + <number>1</number> </property> <property name="value"> <number>256</number> </property> </widget> </item> - <item row="1" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> <string>Reconstruction threshold : </string> </property> </widget> </item> - <item row="1" column="1"> + <item row="2" column="1"> <widget class="QSpinBox" name="thresholdBox"> <property name="maximum"> <number>65536</number> </property> </widget> </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> </item> <item> diff --git a/app/Operations/InverseHoughOp.cpp b/app/Operations/InverseHoughOp.cpp index 931f00d531a415ac50c88a3e94161d1a13da94ed..6d7c1c061ccb36d2eed92c01e448939cd2a2afc7 100644 --- a/app/Operations/InverseHoughOp.cpp +++ b/app/Operations/InverseHoughOp.cpp @@ -40,6 +40,6 @@ void InverseHoughOp::operator()(const imagein::Image_t<double>* img, const std:: if(code!=QDialog::Accepted) return; 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()); } diff --git a/app/Operations/Transforms.cpp b/app/Operations/Transforms.cpp index cdcf5cfebc726fad783b143d2fa21c2b97b3c119..9523498d84fa49bdb423a7842c59fab860379eca 100644 --- a/app/Operations/Transforms.cpp +++ b/app/Operations/Transforms.cpp @@ -181,9 +181,9 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double 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(); @@ -203,15 +203,15 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt int cmpt = 0; 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->getWidth(); ++i) { + for(unsigned int i = 0; i < image->getHeight(); ++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) { cmpt++; - double angle = angleStep * j / 180. * pi; - double rho = rhoStep * i; + double angle = angleStep * i / 180. * pi; + double rho = rhoStep * j; double sinte = sin(angle); double coste = cos(angle); @@ -219,19 +219,19 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt // strcat( buffer, tampon); //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 - sinte * jj) / coste; - if( kk > 0 && kk < size) { - resImg->pixelAt(kk, jj, c) += n; + if( kk > 0 && kk < height) { + 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 - coste * ii) / sinte; - if( kk>0 && kk < size) { - resImg->pixelAt(ii, kk, c) += n; + if( kk>0 && kk < width) { + resImg->pixelAt(kk, ii, c) += n; } } diff --git a/app/Operations/Transforms.h b/app/Operations/Transforms.h index 5c7fbe08858051f65e442f93d45483f30012b082..10449726a9e4e0006d29840526f19b3c35b1d601 100644 --- a/app/Operations/Transforms.h +++ b/app/Operations/Transforms.h @@ -28,7 +28,7 @@ namespace Transforms { 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 - 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 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 );