diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fc8a5de
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/README b/README
new file mode 100644
index 0000000..a35f090
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+Carlos Henrique Júnior
+Gregory Pereira Barbosa
+Lucas Lanna
diff --git a/about.cpp b/about.cpp
new file mode 100644
index 0000000..359e354
--- /dev/null
+++ b/about.cpp
@@ -0,0 +1,21 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "about.h"
+
+About::About(PidMain *parent) : QDialog(parent)
+{ setupUi(this); }
diff --git a/about.h b/about.h
new file mode 100644
index 0000000..3026d8e
--- /dev/null
+++ b/about.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef ABOUT_H
+#define ABOUT_H
+
+#include
+#include "ui_about.h"
+#include "pidmain.h"
+
+class About : public QDialog, public Ui::AboutDialog
+{
+ Q_OBJECT
+
+public:
+ About(PidMain*);
+};
+
+#endif
diff --git a/about.ui b/about.ui
new file mode 100644
index 0000000..c6a4882
--- /dev/null
+++ b/about.ui
@@ -0,0 +1,81 @@
+
+
+
+ AboutDialog
+
+
+ Qt::ApplicationModal
+
+
+
+ 0
+ 0
+ 429
+ 401
+
+
+
+
+ 0
+ 0
+
+
+
+ About us
+
+
+ true
+
+
+ -
+
+
-
+
+
+ <html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Trebuchet MS'; font-size:10pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;">Produzido e mantido por:</p>
+<ul style="-qt-list-indent: 1;"><li style=" font-family:'Sans Serif'; font-size:9pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline; color:#0000ff;">Carlos Henrique Júnior</span></li>
+<li style=" font-family:'Sans Serif'; font-size:9pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline; color:#0000ff;">Gregory Pereira Barbosa</span></li>
+<li style=" font-family:'Sans Serif'; font-size:9pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline; color:#0000ff;">Lucas Lanna</span></li></ul></body></html>
+
+
+
+ -
+
+
+
+
+
+ :/images/camaleon.jpeg
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basicfilter.cpp b/basicfilter.cpp
new file mode 100644
index 0000000..9688abd
--- /dev/null
+++ b/basicfilter.cpp
@@ -0,0 +1,32 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "basicfilter.h"
+#include
+
+bool BasicFilter::H(int u, int v, int r, int x0, int y0, bool a)
+{
+ double hypo = hypot(u - x0, v - y0);
+
+ if (a)
+ return hypo <= r;
+ else
+ return hypo > r;
+}
+
+BasicFilter::~BasicFilter()
+{ }
diff --git a/basicfilter.h b/basicfilter.h
new file mode 100644
index 0000000..10bde1b
--- /dev/null
+++ b/basicfilter.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef BASICFILTER_H
+#define BASICFILTER_H
+
+#include
+#include "complex.h"
+#include "simplefilteredimage.h"
+
+class BasicFilter
+{
+public:
+ virtual QImage* run(Complex*, int, SimpleFilteredImage*)=0;
+ virtual char* desc()=0;
+ virtual ~BasicFilter();
+protected:
+ bool H(int, int, int, int, int, bool);
+};
+
+#endif
diff --git a/butterworth.cpp b/butterworth.cpp
new file mode 100644
index 0000000..d457df4
--- /dev/null
+++ b/butterworth.cpp
@@ -0,0 +1,72 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "butterworth.h"
+#include "fft.h"
+#include
+#include
+
+Butterworth::Butterworth(bool low)
+{
+ this->low = low; // low is true
+}
+
+char* Butterworth::desc()
+{
+ /*char *d;
+ sprintf(d, "Butterworth (passa %s)", low ? "baixa" : "alta");*/
+ return "Butterworth";
+}
+
+QImage* Butterworth::run(Complex* dft, int value, SimpleFilteredImage* img)
+{
+ int width = img->spectrum()->width();
+ int height = img->spectrum()->height();
+ int i, j, pos, size = width * height;
+ double h;
+ int n = QInputDialog::getInteger(img, "Butterworth filter", "n=");
+
+ dft = Fourier::cp(dft, size);
+
+ for (i = 0; i < width; i++)
+ for (j = 0; j < height; j++)
+ {
+ h = H(i, j, value, img->x0(), img->y0(), low, n);
+ pos = (i * height) + j;
+ dft[pos].setIm(dft[pos].im() * h);
+ dft[pos].setRe(dft[pos].re() * h);
+ }
+
+ Complex* inv = Fourier::inverse(dft, size);
+ QImage *im = Fourier::toImage(inv, width, height);
+ delete[] dft;
+ delete[] inv;
+
+ return im;
+}
+
+Butterworth::~Butterworth()
+{ }
+
+double Butterworth::H(int u, int v, int r, int x0, int y0, bool a, int n)
+{
+ double t = !a ? hypot(u - x0, v - y0) / r : r / hypot(u - x0, v - y0);
+ double hypo = 1 / (1 + (sqrt(2) - 1) * pow(t, 2*n) );
+
+ return hypo;
+}
+
diff --git a/butterworth.h b/butterworth.h
new file mode 100644
index 0000000..166417f
--- /dev/null
+++ b/butterworth.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef BUTTERWORTH_H
+#define BUTTERWORTH_H
+
+#include "basicfilter.h"
+#include "complex.h"
+#include
+
+class Butterworth : public BasicFilter
+{
+ bool low;
+public:
+ Butterworth(bool);
+ QImage* run(Complex*, int, SimpleFilteredImage*);
+ char* desc();
+ ~Butterworth();
+protected:
+ double H(int u, int v, int r, int x0, int y0, bool a, int n);
+};
+
+#endif
diff --git a/camaleon.jpeg b/camaleon.jpeg
new file mode 100644
index 0000000..b3a6977
Binary files /dev/null and b/camaleon.jpeg differ
diff --git a/complex.cpp b/complex.cpp
new file mode 100644
index 0000000..f85870c
--- /dev/null
+++ b/complex.cpp
@@ -0,0 +1,115 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include
+#include
+#include "complex.h"
+
+Complex::Complex(double real, double imag)
+{
+ _re = real;
+ _im = imag;
+}
+
+Complex::Complex(Complex *c)
+{
+ _re = c->re();
+ _im = c->im();
+}
+
+double Complex::abso()
+{
+ return log(hypot(_re, _im));
+}
+double Complex::phase()
+{
+ return atan2(_im, _re);
+}
+
+double Complex::magnitude()
+{
+ return abs(_re + _im);
+}
+
+Complex Complex::plus(Complex b)
+{
+ double real = _re + b.re();
+ double imag = _im + b.im();
+ return Complex(real, imag);
+}
+
+Complex Complex::minus(Complex b) {
+ double real = _re - b.re();
+ double imag = _im - b.im();
+ return Complex(real, imag);
+}
+
+Complex Complex::times(Complex b)
+{
+ double real = _re * b.re() - _im * b.im();
+ double imag = _re * b.im() + _im * b.re();
+ return Complex(real, imag);
+}
+
+Complex Complex::times(double alpha)
+{
+ return Complex(alpha * _re, alpha * _im);
+}
+
+Complex Complex::conjugate()
+{
+ return Complex(_re, -1 * _im);
+}
+
+Complex Complex::reciprocal()
+{
+ double scale = _re * _re + _im * _im;
+ return Complex(_re / scale, -1 * _im / scale);
+}
+
+Complex Complex::divides(Complex b)
+{
+ return times(b.reciprocal());
+}
+
+Complex Complex::expo()
+{
+ return Complex(exp(_re) * cos(_im), exp(_re) * sin(_im));
+}
+
+Complex Complex::sino()
+{
+ return Complex(sin(_re) * cosh(_im), cos(_re) * sinh(_im));
+}
+
+Complex Complex::coso()
+{
+ return Complex(cos(_re) * cosh(_im), -1 * sin(_re) * sinh(_im));
+}
+
+Complex Complex::tan()
+{
+ return sino().divides(coso());
+}
+
+Complex Complex::plus(Complex a, Complex b)
+{
+ double real = a.re() + b.re();
+ double imag = a.im() + b.im();
+ return Complex(real, imag);
+}
+
diff --git a/complex.h b/complex.h
new file mode 100644
index 0000000..e277e72
--- /dev/null
+++ b/complex.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef COMPLEX_H
+#define COMPLEX_H
+
+class Complex
+{
+ double _re;
+ double _im;
+public:
+ Complex(double real=0.0, double imag=0.0);
+ Complex(Complex*);
+ double abso();
+ double phase();
+ double magnitude();
+ Complex plus(Complex);
+ Complex minus(Complex);
+ Complex times(Complex);
+ Complex times(double alpha);
+ Complex conjugate();
+ Complex reciprocal();
+ double re() { return _re; }
+ double im() { return _im; }
+ void setRe(double re) { _re = re; }
+ void setIm(double im) { _im = im; }
+ void set(double re, double im) { _re = re; _im = im; }
+ void set(Complex &c) { _re = c.re(); _im = c.im(); }
+ Complex divides(Complex);
+ Complex expo();
+ Complex sino();
+ Complex coso();
+ Complex tan();
+ static Complex plus(Complex, Complex);
+};
+
+#endif
+
diff --git a/fft.cpp b/fft.cpp
new file mode 100755
index 0000000..5f96bd0
--- /dev/null
+++ b/fft.cpp
@@ -0,0 +1,130 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "fft.h"
+#include
+#include
+
+Complex* Fourier::transform(Complex* x, int N)
+{
+ if (N == 1)
+ {
+ Complex* r = new Complex[1];
+ r[0].set(x[0]);
+ return r;
+ }
+ if (N % 2 != 0) { throw NotPowerOfTwo(); }
+
+ Complex* even = new Complex[N / 2];
+ for (int k = 0; k < N / 2; k++)
+ even[k].set(x[2 * k]);
+ Complex* q = transform(even, N / 2);
+
+ Complex* odd = even;
+ for (int k = 0; k < N / 2; k++)
+ odd[k].set(x[2 * k + 1]);
+ Complex* r = transform(odd, N / 2);
+
+ Complex* y = new Complex[N];
+ for (int k = 0; k < N / 2; k++)
+ {
+ double kth = -2 * k * M_PI / N;
+ Complex wk(cos(kth), sin(kth));
+ y[k] = q[k].plus(wk.times(r[k]));
+ y[k + N / 2] = q[k].minus(wk.times(r[k]));
+ }
+
+ delete[] r;
+ delete[] q;
+
+ return y;
+}
+
+Complex* Fourier::inverse(Complex* x, int N)
+{
+ Complex* y = new Complex[N];
+
+ // take conjugate
+ for (int i = 0; i < N; i++)
+ y[i] = x[i].conjugate();
+
+ // compute forward FFT
+ y = transform(y, N);
+
+ // take conjugate again
+ for (int i = 0; i < N; i++)
+ y[i] = y[i].conjugate();
+
+
+ // divide by N
+ for (int i = 0; i < N; i++)
+ y[i] = y[i].times(1.0 / N);
+
+ return y;
+}
+
+Complex* Fourier::fromImage(QImage *img, int &x, int &y)
+{
+ int i, j, k = 0, size;
+ // TODO: always increase the size to decrease after filters
+ /*x = (int) pow(2, round(log10(img->width()) / log10(2)));
+ y = (int) pow(2, round(log10(img->height()) / log10(2)));*/
+ x = img->width(); y = img->height();
+ size = x * y;
+
+ Complex* result = new Complex[size];
+ Complex* res;
+ double pix;
+
+ for (i = 0; i < x; i++)
+ for (j = 0; j < y; j++)
+ {
+ pix = QColor::fromRgba(img->pixel(i, j)).red() * pow(-1, i + j);
+ result[k].set(pix, 0.0);
+ k++;
+ }
+
+ res = transform(result, size);
+ delete[] result;
+
+ return res;
+}
+
+QImage* Fourier::toImage(Complex* inv, int width, int height)
+{
+ QImage *im = new QImage(width, height, QImage::Format_RGB32);
+ int i, j, bright;
+ for (i = 0; i < width; i++)
+ for (j = 0; j < height; j++)
+ {
+ bright = (int)round(abs((int)inv[(i * height) + j].re()));
+ im->setPixel(i, j, qRgb(bright, bright, bright));
+ }
+
+ return im;
+}
+
+Complex* Fourier::cp(Complex* dft, int size)
+{
+ Complex* ndft = new Complex[size];
+
+ for (int i = 0; i < size; i++)
+ ndft[i].set(dft[i]);
+
+ return ndft;
+}
+
diff --git a/fft.h b/fft.h
new file mode 100755
index 0000000..0cef5c6
--- /dev/null
+++ b/fft.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef FFT_H
+#define FFT_H
+
+#include "complex.h"
+#include
+
+namespace Fourier
+{
+ class NotPowerOfTwo { };
+
+ Complex* transform(Complex*, int);
+ Complex* inverse(Complex*, int);
+
+ // Helpers
+ Complex* cp(Complex*, int);
+
+ // Image helpers
+ Complex* fromImage(QImage*, int&, int&);
+ QImage* toImage(Complex*, int, int);
+}
+
+#endif
diff --git a/help.cpp b/help.cpp
new file mode 100644
index 0000000..b3c5d92
--- /dev/null
+++ b/help.cpp
@@ -0,0 +1,21 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "help.h"
+
+Help::Help(PidMain *parent) : QDialog(parent)
+{ setupUi(this); }
diff --git a/help.h b/help.h
new file mode 100644
index 0000000..8674ad4
--- /dev/null
+++ b/help.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef HELP_H
+#define HELP_H
+
+#include
+#include "ui_help.h"
+#include "pidmain.h"
+
+class Help : public QDialog, public Ui::HelpDialog
+{
+ Q_OBJECT
+
+public:
+ Help(PidMain*);
+};
+
+#endif
diff --git a/help.ui b/help.ui
new file mode 100644
index 0000000..26e6735
--- /dev/null
+++ b/help.ui
@@ -0,0 +1,86 @@
+
+
+
+ HelpDialog
+
+
+
+ 0
+ 0
+ 600
+ 600
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 600
+ 600
+
+
+
+
+ 600
+ 600
+
+
+
+ Image Editor Help
+
+
+ -
+
+
+ true
+
+
+ <html><head><meta name="qrichtext" content="1" /><title>Image Editor Help</title><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:x-large; font-weight:600;"><span style=" font-size:x-large;">Abrindo uma imagem</span></p>
+<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; font-weight:600;">Ctrl+O ou File/Open</span></li></ul>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small;">Abre uma imagem que será tratada pelo programa de varias maneiras, dependendo da opção escolhida pelo usuário.</span></p>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:x-large; font-weight:600;"><span style=" font-size:x-large;">Salvar imagem atual</span></p>
+<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; font-weight:600; color:#000000;">Ctrl+Shift+S ou File/Save</span></li></ul>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small;">Salva a imagem atual e suas alterações que foram realizadas até este momento em um diretório a ser escolhido.</span></p>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small;">Com este recurso você pode salvar a imagem original, sua versão em escala de cinza ou ainda o espectro de fourier</span></p>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:x-large; font-weight:600;"><span style=" font-size:x-large;">Gerar escala de cinza</span></p>
+<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; font-weight:600;">Ctrl+G ou Image/Generate Gray Scale</span> </li></ul>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; color:#000000;">Gera uma versão na escala de cinza da imagem, partindo do pressuposto que está é colorida. Uma função é utilizada para alterar os valores RGB(red, green, blue) de cada pixel da imagem para transformá-lo em um pixel de tom cinza.</span></p>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:x-large; font-weight:600;"><span style=" font-size:x-large;">Gerar Histograma</span></p>
+<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; font-weight:600; color:#000000;">Ctrl+H ou Image/Generate Histogram</span></li></ul>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small;">Gera o histograma da imagem após ser transformada na versão em escala de cinza, feito com base na distribuição de freqüências de tons de cinza presentes na imagem, normalmente um gráfico de barras verticais.</span></p>
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:x-large; font-weight:600;"><span style=" font-size:x-large;">Espectro de Fourier</span></p>
+<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small; font-weight:600; color:#000000;">Ctrl+F ou Image/Generate Fourier Spectrum</span></li></ul>
+<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:small;">Gera o espectro de Fourier da imagem atual utilizando uma função que aplica a transformada de Fourier em uma imagem de duas dimensões. O espectro de Fourier é o gráfico da magnitude versus freqüência, aonde a freqüência corresponde a freqüência na forma de senos e cosenos.</span></p></body></html>
+
+
+
+
+
+
+
+
diff --git a/histogram.cpp b/histogram.cpp
new file mode 100644
index 0000000..809e96e
--- /dev/null
+++ b/histogram.cpp
@@ -0,0 +1,82 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include
+#include
+#include
+#include "histogram.h"
+
+Histogram::Histogram(int idx[256]) : QPixmap(HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT)
+{
+ perClass = 256 / _HISTOGRAM_CLASSES;
+
+ for (int i = 0; i < _HISTOGRAM_CLASSES; i++)
+ {
+ int val = 0;
+ for (int j = i * perClass; j < (i+1) * perClass - 1; j++)
+ val = val + idx[j];
+ indexes[i] = val;
+ }
+
+ generate();
+}
+
+void Histogram::generate()
+{
+ fill();
+ QPainter painter(this);
+ int max = indexes[0];
+ for (int i = 0; i < _HISTOGRAM_CLASSES; i++)
+ if (indexes[i] > max)
+ max = indexes[i];
+
+ max = max + (100 - max % 100);
+
+ paintGraphBase(&painter, max);
+
+ for (int i = 0; i < _HISTOGRAM_CLASSES; i++)
+ paintBar(&painter, max, i);
+}
+
+void Histogram::paintGraphBase(QPainter *painter, int max)
+{
+ int interval = max / 10;
+ int posInterval = ZERO_POINT / 10;
+ for (int i = 0; i <= 10; i++)
+ {
+ int val = max - i * interval;
+ int pos = posInterval * i + TOP_SPACE;
+ painter->drawText(0, pos - 5, QString::number(val));
+ painter->drawLine(0, pos, (BAR_WIDTH + BAR_SPACE) * _HISTOGRAM_CLASSES + SIDE_SPACE, pos);
+ }
+}
+
+void Histogram::paintBar(QPainter *painter, int max, int i)
+{
+ int size = qRound(indexes[i] * (ZERO_POINT - TOP_SPACE) / max) + 1;
+
+ QLinearGradient color;
+ int starting_color = i * perClass;
+ int ending_color = (i + 1) * perClass - 1;
+ color.setColorAt(0, QColor(starting_color, starting_color, starting_color));
+ color.setColorAt(1, QColor(ending_color, ending_color, ending_color));
+ painter->setBrush(color);
+ painter->drawRect(i * (BAR_WIDTH + BAR_SPACE) + SIDE_SPACE, ZERO_POINT - size + TOP_SPACE, BAR_WIDTH, size);
+ painter->drawText(i * (BAR_WIDTH + BAR_SPACE) + SIDE_SPACE, ZERO_POINT + 12 + TOP_SPACE, QString::number(i));
+
+ painter->drawText(_HISTOGRAM_CLASSES * (BAR_WIDTH + BAR_SPACE) + SIDE_SPACE + 10, i * 13 + 20, QString::number(i) + " = " + QString::number(starting_color) + " - " + QString::number(ending_color));
+}
diff --git a/histogram.h b/histogram.h
new file mode 100644
index 0000000..1394a72
--- /dev/null
+++ b/histogram.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef HISTOGRAM_H
+#define HISTOGRAM_H
+
+#include
+#include
+#define _HISTOGRAM_CLASSES 32
+#define BAR_WIDTH 15
+#define BAR_SPACE 3
+#define ZERO_POINT 400
+#define TOP_SPACE 20
+#define SIDE_SPACE 40
+#define HISTOGRAM_WIDTH (SIDE_SPACE + ((BAR_WIDTH + BAR_SPACE) * _HISTOGRAM_CLASSES))
+#define HISTOGRAM_HEIGHT (HISTOGRAM_WIDTH, ZERO_POINT + TOP_SPACE + 20)
+
+class Histogram : public QPixmap
+{
+ int indexes[_HISTOGRAM_CLASSES];
+ int perClass;
+public:
+ Histogram(int[255]);
+ void generate();
+private:
+ void paintGraphBase(QPainter*, int);
+ void paintBar(QPainter*, int, int);
+};
+
+#endif
diff --git a/ideal.ui b/ideal.ui
new file mode 100644
index 0000000..0184fff
--- /dev/null
+++ b/ideal.ui
@@ -0,0 +1,88 @@
+
+
+
+ IdealFilterDialog
+
+
+
+ 0
+ 0
+ 511
+ 433
+
+
+
+ Ideal Filter
+
+
+ -
+
+
+
+
+ 14
+ 14
+ 503
+ 389
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+ Show guide lines
+
+
+ true
+
+
+
+ -
+
+
+ Apply
+
+
+
+
+
+
+
+
+
+ IdealFilteredImage
+ QLabel
+
+
+
+ QScrollArea
+ QWidget
+
+ 1
+
+
+
+
+
diff --git a/idealfilter.cpp b/idealfilter.cpp
new file mode 100644
index 0000000..5545fd9
--- /dev/null
+++ b/idealfilter.cpp
@@ -0,0 +1,71 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "idealfilter.h"
+#include "complex.h"
+#include "fft.h"
+#include
+#include
+
+IdealFilter::IdealFilter(PidMain *parent, ImageTabs* imgs) : QDialog(parent),
+images(imgs)
+{
+ setupUi(this);
+ scrollArea->setWidget(imageLabel);
+ imageLabel->setSpectrum(image());
+
+ connect(applyButton, SIGNAL( clicked() ), this, SLOT( applyFilter() ));
+ connect(showGuideLines, SIGNAL( toggled(bool) ), this, SLOT( toggleShowGuideLines(bool) ));
+}
+
+void IdealFilter::applyFilter()
+{
+ int width = image()->width();
+ int height = image()->height();
+ int i, j, k, size = width * height;
+
+ Complex* dft = Fourier::cp(images->getDFT(), size);
+
+ for (i = 0; i < width; i++)
+ for (j = 0; j < height; j++)
+ for (k = 0; k < imageLabel->selections().size(); k++)
+ if (imageLabel->selections().at(k).contains(i, j))
+ {
+ dft[(i * height) + j].set(0.0, 0.0);
+ break;
+ }
+
+ Complex* inv = Fourier::inverse(dft, size);
+ QImage *im = Fourier::toImage(inv, width, height);
+ delete[] dft;
+ delete[] inv;
+
+ images->addImage("Special Filter", im);
+ close();
+}
+
+QImage* IdealFilter::image()
+{
+ return images->getSpectrum();
+}
+
+void IdealFilter::toggleShowGuideLines(bool a)
+{
+ imageLabel->setShowGuideLines(a);
+ imageLabel->update();
+}
+
diff --git a/idealfilter.h b/idealfilter.h
new file mode 100644
index 0000000..6e8c9ae
--- /dev/null
+++ b/idealfilter.h
@@ -0,0 +1,22 @@
+#ifndef IDEALFILTER_H
+#define IDEALFILTER_H
+
+#include
+#include "ui_ideal.h"
+#include "pidmain.h"
+#include "imagetabs.h"
+
+class IdealFilter : public QDialog, public Ui::IdealFilterDialog
+{
+ Q_OBJECT
+ ImageTabs* images;
+public:
+ IdealFilter(PidMain*, ImageTabs*);
+public slots:
+ void applyFilter();
+ void toggleShowGuideLines(bool);
+private:
+ QImage* image();
+};
+
+#endif
diff --git a/idealfilteredimage.cpp b/idealfilteredimage.cpp
new file mode 100644
index 0000000..9a1b300
--- /dev/null
+++ b/idealfilteredimage.cpp
@@ -0,0 +1,142 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "idealfilteredimage.h"
+#include
+#include
+
+IdealFilteredImage::IdealFilteredImage(QWidget *parent) : QLabel(parent)
+{
+ rubberBand = NULL;
+ showGuideLines = true;
+}
+
+void IdealFilteredImage::mousePressEvent(QMouseEvent *event)
+{
+ selOrigin = event->pos();
+ if (!rubberBand)
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
+ rubberBand->setGeometry(QRect(selOrigin, QSize()));
+ rubberBand->show();
+}
+
+void IdealFilteredImage::mouseMoveEvent(QMouseEvent *event)
+{
+ rubberBand->setGeometry(QRect(selOrigin, event->pos()).normalized());
+}
+
+void IdealFilteredImage::mouseReleaseEvent(QMouseEvent *event)
+{
+ rubberBand->hide();
+ selDest = event->pos();
+ int deltaX = selOrigin.x() - selDest.x();
+ int deltaY = selOrigin.y() - selDest.y();
+
+ if (!(deltaX < 0 && deltaY < 0))
+ {
+ if (deltaX > 0 && deltaY > 0)
+ {
+ // \<
+ QPoint tmp = selDest;
+ selDest = selOrigin;
+ selOrigin = tmp;
+ }
+ else if (deltaX < 0 && deltaY > 0)
+ {
+ // />
+ int tmp = selOrigin.y();
+ selOrigin.setY(selDest.y());
+ selDest.setY(tmp);
+ }
+ else if (deltaX > 0 && deltaY < 0)
+ {
+ // /<
+ int tmp = selOrigin.x();
+ selOrigin.setX(selDest.x());
+ selDest.setX(tmp);
+ }
+ }
+
+ _selections << QRect(selOrigin, selDest);
+
+ // reflex
+ int width = abs(deltaX);
+ int height = abs(deltaY);
+ int rx = _x0 + _x0 - selOrigin.x() - width;
+ int ry = _y0 + _y0 - selOrigin.y() - height;
+ _selections << QRect(QPoint(rx, ry), QPoint(rx + width, ry + height));
+
+ update();
+ // determine selection, for example using QRect::intersects()
+ // and QRect::contains().
+}
+
+void
+IdealFilteredImage::setSpectrum(QImage* s)
+{
+ spec = s;
+ setPixmap(QPixmap::fromImage(*spec));
+ _x0 = (int) round(spec->width() / 2.f);
+ _y0 = (int) round(spec->height() / 2.f);
+ setFixedHeight(spec->height());
+ setFixedWidth(spec->width());
+}
+
+int IdealFilteredImage::y0()
+{
+ return _y0;
+}
+
+int IdealFilteredImage::x0()
+{
+ return _x0;
+}
+
+void IdealFilteredImage::paintEvent(QPaintEvent* ev)
+{
+ QLabel::paintEvent(ev);
+ QPainter painter(this);
+
+ painter.setPen(Qt::black);
+ painter.setBrush(Qt::black);
+
+ for (int i = 0; i < _selections.size(); i++)
+ painter.drawRect(_selections[i]);
+
+ if (showGuideLines)
+ {
+ painter.setPen(Qt::red);
+ painter.drawLine(0, _y0, spectrum()->width() - 1, _y0);
+ painter.drawLine(_x0, 0, _x0, spectrum()->height() - 1);
+ }
+}
+
+void IdealFilteredImage::setShowGuideLines(bool a)
+{
+ showGuideLines = a;
+}
+
+QImage* IdealFilteredImage::spectrum()
+{
+ return spec;
+}
+
+QList IdealFilteredImage::selections()
+{
+ return _selections;
+}
+
diff --git a/idealfilteredimage.h b/idealfilteredimage.h
new file mode 100644
index 0000000..f62a480
--- /dev/null
+++ b/idealfilteredimage.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef IDEAL_FILTERED_IMAGE_H
+#define IDEAL_FILTERED_IMAGE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+class IdealFilteredImage : public QLabel
+{
+ Q_OBJECT
+ QImage *spec;
+ int _x0, _y0; // image center
+ QList _selections;
+ bool showGuideLines;
+
+ // current selection
+ QRubberBand *rubberBand;
+ QPoint selOrigin, selDest;
+public:
+ IdealFilteredImage(QWidget*);
+ void setSpectrum(QImage*);
+ QImage* spectrum();
+ int y0();
+ int x0();
+ void paintEvent(QPaintEvent*);
+ void setShowGuideLines(bool);
+ QList selections();
+protected:
+ void mousePressEvent(QMouseEvent*);
+ void mouseMoveEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
+};
+
+#endif
diff --git a/images.qrc b/images.qrc
new file mode 100644
index 0000000..b93e02b
--- /dev/null
+++ b/images.qrc
@@ -0,0 +1,22 @@
+
+
+
+
+ camaleon.jpeg
+
+
diff --git a/imagetabs.cpp b/imagetabs.cpp
new file mode 100644
index 0000000..b58bfc0
--- /dev/null
+++ b/imagetabs.cpp
@@ -0,0 +1,159 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "imagetabs.h"
+#include "histogram.h"
+#include "fft.h"
+#include
+#include
+#include
+#include
+
+ImageTabs::ImageTabs(QWidget *parent, QString imageLocation) : QTabWidget(parent)
+{
+ original = new QImage(imageLocation);
+ bool grayScale = original->isGrayscale();
+ gray = (grayScale) ? original : NULL;
+ dft = NULL;
+ spectrum = NULL;
+
+ addImage("Original" + QString((grayScale) ? " (Grayscale)" : ""), original);
+}
+
+QImage*
+ImageTabs::getOriginal()
+{
+ return original;
+}
+
+QImage*
+ImageTabs::getGray()
+{
+ generateGrayScale();
+ return gray;
+}
+
+QImage*
+ImageTabs::getSpectrum()
+{
+ if (dft == NULL)
+ dft = Fourier::fromImage(getGray(), spectX, spectY);
+ if (spectrum == NULL)
+ {
+ spectrum = new QImage(spectX, spectY, QImage::Format_RGB32);
+ int bright;
+ int pos;
+
+ for (int i = 0; i < spectX; i++)
+ for (int j = 0; j < spectY; j++)
+ {
+ pos = (i * spectY) + j;
+ bright = (int) dft[pos].abso();
+ spectrum->setPixel(i, j, qRgb(bright, bright, bright));
+ }
+ }
+
+ return spectrum;
+}
+
+QImage
+ImageTabs::getCurrent()
+{
+ QScrollArea *scroll = (QScrollArea*)currentWidget();
+ return ((QLabel*)scroll->widget())->pixmap()->toImage();
+}
+
+void
+ImageTabs::generateGrayScale()
+{
+ if (gray == NULL)
+ {
+ gray = new QImage(*original);
+ QRgb grayPix;
+ int bright;
+
+ for (int i = 0; i < gray->width(); i++)
+ for (int j = 0; j < gray->height(); j++)
+ {
+ QColor curPix = QColor::fromRgba(gray->pixel(i, j));
+ bright = qRound(0.3 * curPix.red() + 0.5 * curPix.green() + 0.2 * curPix.blue());
+ grayPix = qRgb(bright, bright, bright);
+ gray->setPixel(i, j, grayPix);
+ }
+
+ addImage("Gray Scale", gray);
+ }
+}
+
+void
+ImageTabs::generateHistogram()
+{
+ generateGrayScale();
+
+ int indexes[256];
+ for (int i = 0; i < 256; i++)
+ indexes[i] = 0;
+
+ for (int i = 0; i < gray->width(); i++)
+ for (int j = 0; j < gray->height(); j++)
+ {
+ QColor curPix = QColor::fromRgba(gray->pixel(i, j));
+ indexes[curPix.red()]++;
+ }
+
+ QLabel *hView = new QLabel(this);
+ hView->setPixmap(Histogram(indexes));
+
+ QScrollArea *scroll = new QScrollArea;
+ scroll->setWidget(hView);
+
+ addTab(scroll, "Histogram");
+ setCurrentWidget(scroll);
+}
+
+void
+ImageTabs::addImage(QString label, QImage *img)
+{
+ QLabel *view = new QLabel(this);
+ view->setPixmap(QPixmap::fromImage(*img));
+
+ QScrollArea *scroll = new QScrollArea;
+ scroll->setWidget(view);
+
+ addTab(scroll, label);
+ setCurrentWidget(scroll);
+}
+
+Complex*
+ImageTabs::getDFT()
+{
+ return dft;
+}
+
+ImageTabs::~ImageTabs()
+{
+ if (dft != NULL)
+ delete[] dft;
+
+ if (gray != original)
+ delete gray;
+ delete original;
+
+ if (spectrum != NULL)
+ delete spectrum;
+}
+
diff --git a/imagetabs.h b/imagetabs.h
new file mode 100644
index 0000000..8268ebb
--- /dev/null
+++ b/imagetabs.h
@@ -0,0 +1,30 @@
+#ifndef IMAGETABS_H
+#define IMAGETABS_H
+
+#include
+#include
+#include
+#include "complex.h"
+
+class ImageTabs : public QTabWidget
+{
+ Q_OBJECT
+
+ QImage *original, *gray, *spectrum;
+ int spectX, spectY;
+ Complex* dft;
+
+public:
+ ImageTabs(QWidget *parent, QString imageLocation);
+ QImage* getOriginal();
+ QImage* getGray();
+ QImage* getSpectrum();
+ Complex* getDFT();
+ QImage getCurrent();
+ void generateGrayScale();
+ void generateHistogram();
+ void addImage(QString, QImage*);
+ ~ImageTabs();
+};
+
+#endif
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..165437c
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,34 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include
+#include
+#include
+#include "pidmain.h"
+#include "complex.h"
+#include "fft.h"
+
+int
+main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ PidMain *dialog = new PidMain;
+
+ dialog->show();
+ return app.exec();
+}
+
diff --git a/main.ui b/main.ui
new file mode 100644
index 0000000..27cf852
--- /dev/null
+++ b/main.ui
@@ -0,0 +1,200 @@
+
+
+
+ PIDMainWindow
+
+
+
+ 0
+ 0
+ 800
+ 600
+
+
+
+ Blind Camaleon v1.0a
+
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+
+
+
+
+
+
+ &Open Image
+
+
+ Ctrl+O
+
+
+
+
+ true
+
+
+ Generate &Gray Scale
+
+
+ Ctrl+G
+
+
+
+
+ &Save Current As...
+
+
+ Ctrl+Shift+S
+
+
+
+
+ &Help
+
+
+ F1
+
+
+
+
+ &About Blind Camaleon
+
+
+
+
+ Generate &Histogram
+
+
+ Ctrl+H
+
+
+
+
+ Generate &Fourier Spectrum
+
+
+ Ctrl+F
+
+
+
+
+ Passa alta
+
+
+ Ctrl+P, A
+
+
+
+
+ Passa baixa
+
+
+ Ctrl+P, B
+
+
+
+
+ Ideal
+
+
+ Ctrl+I
+
+
+
+
+ Passa alta
+
+
+
+
+ Passa baixa
+
+
+
+
+
+ QMdiArea
+ QFrame
+
+ 1
+
+
+
+
+
diff --git a/passaalta.cpp b/passaalta.cpp
new file mode 100644
index 0000000..45ec3b2
--- /dev/null
+++ b/passaalta.cpp
@@ -0,0 +1,45 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "passaalta.h"
+#include "fft.h"
+#include
+
+QImage* PassaAlta::run(Complex* dft, int value, SimpleFilteredImage* img)
+{
+ int width = img->spectrum()->width();
+ int height = img->spectrum()->height();
+ int i, j, size = width * height;
+
+ dft = Fourier::cp(dft, size);
+
+ for (i = 0; i < width; i++)
+ for (j = 0; j < height; j++)
+ if (H(i, j, value, img->x0(), img->y0(), true))
+ dft[(i * height) + j].set(0.0, 0.0);
+
+ Complex* inv = Fourier::inverse(dft, size);
+ QImage *im = Fourier::toImage(inv, width, height);
+ delete[] dft;
+ delete[] inv;
+
+ return im;
+}
+
+PassaAlta::~PassaAlta()
+{ }
+
diff --git a/passaalta.h b/passaalta.h
new file mode 100644
index 0000000..1f698d4
--- /dev/null
+++ b/passaalta.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef PASSAALTA_H
+#define PASSAALTA_H
+
+#include "basicfilter.h"
+#include "complex.h"
+#include
+
+class PassaAlta : public BasicFilter
+{
+public:
+ QImage* run(Complex*, int, SimpleFilteredImage*);
+ char* desc() { return "Passa alta"; }
+ ~PassaAlta();
+};
+
+#endif
diff --git a/passabaixa.cpp b/passabaixa.cpp
new file mode 100644
index 0000000..067aeea
--- /dev/null
+++ b/passabaixa.cpp
@@ -0,0 +1,45 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "passabaixa.h"
+#include "fft.h"
+#include
+
+QImage* PassaBaixa::run(Complex* dft, int value, SimpleFilteredImage* img)
+{
+ int width = img->spectrum()->width();
+ int height = img->spectrum()->height();
+ int i, j, size = width * height;
+
+ dft = Fourier::cp(dft, size);
+
+ for (i = 0; i < width; i++)
+ for (j = 0; j < height; j++)
+ if (H(i, j, value, img->x0(), img->y0(), false))
+ dft[(i * height) + j].set(0.0, 0.0);
+
+ Complex* inv = Fourier::inverse(dft, size);
+ QImage *im = Fourier::toImage(inv, width, height);
+ delete[] dft;
+ delete[] inv;
+
+ return im;
+}
+
+PassaBaixa::~PassaBaixa()
+{ }
+
diff --git a/passabaixa.h b/passabaixa.h
new file mode 100644
index 0000000..21b1b26
--- /dev/null
+++ b/passabaixa.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#ifndef PASSABAIXA_H
+#define PASSABAIXA_H
+
+#include "basicfilter.h"
+#include "complex.h"
+#include
+
+class PassaBaixa : public BasicFilter
+{
+public:
+ QImage* run(Complex*, int, SimpleFilteredImage*);
+ char* desc() { return "Passa baixa"; }
+ ~PassaBaixa();
+};
+
+#endif
diff --git a/pid.pro b/pid.pro
new file mode 100644
index 0000000..21d51da
--- /dev/null
+++ b/pid.pro
@@ -0,0 +1,33 @@
+###########
+## This file is part of Blind Camaleon.
+##
+## Blind Camaleon 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.
+##
+## Blind Camaleon 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 Blind Camaleon. If not, see .
+###########
+
+
+# files
+HEADERS = pidmain.h about.h help.h histogram.h imagetabs.h complex.h simplefilter.h simplefilteredimage.h fft.h basicfilter.h passaalta.h passabaixa.h idealfilter.h idealfilteredimage.h butterworth.h
+SOURCES = pidmain.cpp about.cpp help.cpp main.cpp histogram.cpp imagetabs.cpp complex.cpp simplefilter.cpp simplefilteredimage.cpp fft.cpp passabaixa.cpp passaalta.cpp basicfilter.cpp idealfilter.cpp idealfilteredimage.cpp butterworth.cpp
+FORMS = main.ui about.ui help.ui simplefilter.ui ideal.ui
+RESOURCES = images.qrc
+
+# configurations
+TEMPLATE = app
+CONFIG += release
+
+# install
+target.path = pidmain
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS##.pro
+sources.path = .
+INSTALLS += target sources
diff --git a/pidmain.cpp b/pidmain.cpp
new file mode 100644
index 0000000..9d5136f
--- /dev/null
+++ b/pidmain.cpp
@@ -0,0 +1,199 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include
+#include
+#include
+#include "pidmain.h"
+#include "about.h"
+#include "help.h"
+#include "imagetabs.h"
+#include "simplefilter.h"
+#include "idealfilter.h"
+#include "butterworth.h"
+#include "passaalta.h"
+#include "passabaixa.h"
+
+PidMain::PidMain(QWidget *parent) : QMainWindow(parent)
+{
+ setupUi(this);
+
+ // Connect signals
+ // File
+ connect(menuOpenImage, SIGNAL( triggered() ), this, SLOT( openImage() ));
+ connect(menuSaveCurrent, SIGNAL( triggered() ), this, SLOT( saveCurrentAs() ));
+
+ // Image
+ connect(menuGenerateGrayScale, SIGNAL( triggered() ), this, SLOT( generateGrayScale() ));
+ connect(menuGenerateHistogram, SIGNAL( triggered() ), this, SLOT( generateHistogram() ));
+
+ // Help
+ connect(menuOpenAbout, SIGNAL( triggered() ), this, SLOT( openAboutDialog() ));
+ connect(menuOpenHelp, SIGNAL( triggered() ), this, SLOT( openHelpDialog() ));
+
+ // Filters
+ connect(menuFiltersAltaIdeal, SIGNAL( triggered() ), this, SLOT( openPassaAltaIdeal() ));
+ connect(menuFiltersBaixaIdeal, SIGNAL( triggered() ), this, SLOT( openPassaBaixaIdeal() ));
+ connect(menuFiltersIdeal, SIGNAL( triggered() ), this, SLOT( openIdeal() ));
+ connect(menuButterworthBaixa, SIGNAL( triggered() ), this, SLOT( openButterworthBaixa() ));
+ connect(menuButterworthAlta, SIGNAL( triggered() ), this, SLOT( openButterworthAlta() ));
+
+ // initializing some widgets
+ mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+}
+
+void
+PidMain::openImage()
+{
+ QString path;
+
+ path = QFileDialog::getOpenFileName(this,
+ "Choose an image file to open",
+ QString::null,
+ "*.jpg *.jpeg");
+
+ if (path != NULL)
+ {
+ ImageTabs *img = new ImageTabs(mdiArea, path);
+ QMdiSubWindow *imgWindow = mdiArea->addSubWindow(img);
+ imgWindow->setWindowTitle(path);
+ imgWindow->show();
+ }
+}
+
+void
+PidMain::openHelpDialog()
+{
+ Help a(this);
+ a.exec();
+}
+
+void
+PidMain::openAboutDialog()
+{
+ About a(this);
+ a.exec();
+}
+
+void
+PidMain::generateGrayScale()
+{
+ ImageTabs* current = getCurrentImageWindow();
+
+ if (current != NULL)
+ current->generateGrayScale();
+}
+
+void
+PidMain::generateHistogram()
+{
+ ImageTabs* current = getCurrentImageWindow();
+
+ if (current != NULL)
+ current->generateHistogram();
+}
+
+void
+PidMain::saveCurrentAs()
+{
+ ImageTabs* current = getCurrentImageWindow();
+
+ if (current != NULL)
+ {
+ QString path;
+
+ path = QFileDialog::getSaveFileName(this,
+ "Choose an image file to open",
+ QString::null,
+ "Images (*.jpg *.png)");
+
+ if (path != NULL)
+ current->getCurrent().save(path);
+ }
+}
+
+void
+PidMain::openPassaAltaIdeal()
+{
+ ImageTabs* current = getCurrentImageWindow();
+ if (current != NULL)
+ {
+ SimpleFilter *filter = new SimpleFilter(this, current, new PassaAlta);
+ filter->setAttribute(Qt::WA_DeleteOnClose);
+ filter->exec();
+ }
+}
+
+void
+PidMain::openPassaBaixaIdeal()
+{
+ ImageTabs* current = getCurrentImageWindow();
+ if (current != NULL)
+ {
+ SimpleFilter *filter = new SimpleFilter(this, current, new PassaBaixa);
+ filter->setAttribute(Qt::WA_DeleteOnClose);
+ filter->exec();
+ }
+}
+
+void
+PidMain::openButterworthBaixa()
+{
+ ImageTabs* current = getCurrentImageWindow();
+ if (current != NULL)
+ {
+ SimpleFilter *filter = new SimpleFilter(this, current, new Butterworth(false));
+ filter->setAttribute(Qt::WA_DeleteOnClose);
+ filter->exec();
+ }
+}
+
+void
+PidMain::openButterworthAlta()
+{
+ ImageTabs* current = getCurrentImageWindow();
+ if (current != NULL)
+ {
+ SimpleFilter *filter = new SimpleFilter(this, current, new Butterworth(true));
+ filter->setAttribute(Qt::WA_DeleteOnClose);
+ filter->exec();
+ }
+}
+
+void
+PidMain::openIdeal()
+{
+ ImageTabs* current = getCurrentImageWindow();
+ if (current != NULL)
+ {
+ IdealFilter *filter = new IdealFilter(this, current);
+ //filter->setAttribute(Qt::WA_DeleteOnClose);
+ filter->exec();
+ }
+}
+
+ImageTabs*
+PidMain::getCurrentImageWindow()
+{
+ QMdiSubWindow *activeWindow = mdiArea->activeSubWindow();
+
+ if (activeWindow == NULL)
+ return NULL;
+ else
+ return (ImageTabs*)activeWindow->widget();
+}
diff --git a/pidmain.h b/pidmain.h
new file mode 100644
index 0000000..825679c
--- /dev/null
+++ b/pidmain.h
@@ -0,0 +1,31 @@
+#ifndef PID_H
+#define PID_H
+
+#include "imagetabs.h"
+#include "ui_main.h"
+
+class PidMain : public QMainWindow, public Ui::PIDMainWindow
+{
+ Q_OBJECT
+
+public:
+ PidMain(QWidget *parent = 0);
+ ImageTabs* getCurrentImageWindow();
+
+public slots:
+ void openImage();
+ void generateGrayScale();
+ void generateHistogram();
+ void saveCurrentAs();
+ void openAboutDialog();
+ void openHelpDialog();
+
+ // Filters
+ void openPassaAltaIdeal();
+ void openPassaBaixaIdeal();
+ void openIdeal();
+ void openButterworthAlta();
+ void openButterworthBaixa();
+};
+
+#endif
diff --git a/simplefilter.cpp b/simplefilter.cpp
new file mode 100644
index 0000000..7e9a02d
--- /dev/null
+++ b/simplefilter.cpp
@@ -0,0 +1,65 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "simplefilter.h"
+#include "simplefilteredimage.h"
+#include
+#include
+
+SimpleFilter::SimpleFilter(PidMain *parent, ImageTabs* imgs, BasicFilter* filter) : QDialog(parent),
+images(imgs)
+{
+ setupUi(this);
+ this->filter = filter;
+ scrollArea->setWidget(imageLabel);
+ imageLabel->setSpectrum(image());
+ filterPosition->setMaximum((int) round(hypot(imageLabel->x0(), imageLabel->y0())));
+ filterPosition->setMinimum(0);
+
+ connect(imageLabel, SIGNAL( imageClicked() ), this, SLOT( setFilterPosition() ));
+ connect(filterPosition, SIGNAL( valueChanged(int) ), this, SLOT( setFilterPosition(int) ));
+ connect(applyButton, SIGNAL( clicked() ), this, SLOT( applyFilter() ));
+}
+
+void SimpleFilter::setFilterPosition()
+{
+ filterPosition->setValue(imageLabel->z());
+ imageLabel->update();
+}
+
+void SimpleFilter::setFilterPosition(int p)
+{
+ imageLabel->setZ(p);
+ imageLabel->update();
+}
+
+void SimpleFilter::applyFilter()
+{
+ images->addImage(QString().sprintf("%s [%d]", filter->desc(), filterPosition->value()), filter->run(images->getDFT(), filterPosition->value(), imageLabel));
+ close();
+}
+
+QImage* SimpleFilter::image()
+{
+ return images->getSpectrum();
+}
+
+SimpleFilter::~SimpleFilter()
+{
+ delete filter;
+}
+
diff --git a/simplefilter.h b/simplefilter.h
new file mode 100644
index 0000000..a14f95b
--- /dev/null
+++ b/simplefilter.h
@@ -0,0 +1,27 @@
+#ifndef SIMPLE_FILTER_H
+#define SIMPLE_FILTER_H
+
+#include
+#include "simplefilteredimage.h"
+#include "ui_simplefilter.h"
+#include "pidmain.h"
+#include "imagetabs.h"
+#include "basicfilter.h"
+
+class SimpleFilter : public QDialog, public Ui::SimpleFilterDialog
+{
+ Q_OBJECT
+ ImageTabs* images;
+ BasicFilter* filter;
+public:
+ SimpleFilter(PidMain*, ImageTabs*, BasicFilter*);
+ ~SimpleFilter();
+public slots:
+ void setFilterPosition();
+ void setFilterPosition(int);
+ void applyFilter();
+private:
+ QImage* image();
+};
+
+#endif
diff --git a/simplefilter.ui b/simplefilter.ui
new file mode 100644
index 0000000..6b46559
--- /dev/null
+++ b/simplefilter.ui
@@ -0,0 +1,125 @@
+
+
+
+ SimpleFilterDialog
+
+
+ Qt::WindowModal
+
+
+
+ 0
+ 0
+ 843
+ 477
+
+
+
+ Apply Filter
+
+
+ -
+
+
+
+
+ 14
+ 14
+ 628
+ 91
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ K=
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Apply!
+
+
+
+
+
+
+
+
+
+ SimpleFilteredImage
+ QLabel
+
+
+
+ QScrollArea
+ QWidget
+
+ 1
+
+
+
+
+
diff --git a/simplefilteredimage.cpp b/simplefilteredimage.cpp
new file mode 100644
index 0000000..7d9b60f
--- /dev/null
+++ b/simplefilteredimage.cpp
@@ -0,0 +1,81 @@
+/*
+ * This file is part of Blind Camaleon.
+ *
+ * Blind Camaleon 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.
+ *
+ * Blind Camaleon 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 Blind Camaleon. If not, see .
+ */
+
+#include "simplefilteredimage.h"
+#include
+#include
+
+SimpleFilteredImage::SimpleFilteredImage(QDialog*)
+{ }
+
+SimpleFilteredImage::SimpleFilteredImage(QWidget *parent) : QLabel(parent)
+{ }
+
+void
+SimpleFilteredImage::mouseReleaseEvent(QMouseEvent *event)
+{
+ QPoint p = event->pos();
+ _z = (int) round(hypot(p.x() - _x0, p.y() - _y0));
+ emit imageClicked();
+}
+
+void
+SimpleFilteredImage::setSpectrum(QImage* s)
+{
+ spec = s;
+ setPixmap(QPixmap::fromImage(*spec));
+ _x0 = (int) round(spec->width() / 2.f);
+ _y0 = (int) round(spec->height() / 2.f);
+ setFixedHeight(spec->height());
+ setFixedWidth(spec->width());
+}
+
+void
+SimpleFilteredImage::setZ(int z)
+{
+ _z = z;
+}
+
+int SimpleFilteredImage::y0()
+{
+ return _y0;
+}
+
+int SimpleFilteredImage::x0()
+{
+ return _x0;
+}
+
+int SimpleFilteredImage::z()
+{
+ return _z;
+}
+
+void SimpleFilteredImage::paintEvent(QPaintEvent* ev)
+{
+ QLabel::paintEvent(ev);
+ QPainter painter(this);
+ int d = _z * 2;
+ painter.setPen(Qt::red);
+ painter.drawEllipse(_x0 - _z, _y0 - _z, d, d);
+}
+
+QImage* SimpleFilteredImage::spectrum()
+{
+ return spec;
+}
+
diff --git a/simplefilteredimage.h b/simplefilteredimage.h
new file mode 100644
index 0000000..71d63f9
--- /dev/null
+++ b/simplefilteredimage.h
@@ -0,0 +1,30 @@
+#ifndef SIMPLE_FILTERED_IMAGE_H
+#define SIMPLE_FILTERED_IMAGE_H
+
+#include
+#include
+#include
+#include
+
+class SimpleFilteredImage : public QLabel
+{
+ Q_OBJECT
+ QImage *spec;
+ int _x0, _y0, _z;
+public:
+ SimpleFilteredImage(QDialog*);
+ SimpleFilteredImage(QWidget*);
+ void setSpectrum(QImage*);
+ QImage* spectrum();
+ int y0();
+ int x0();
+ int z();
+ void setZ(int);
+ void paintEvent(QPaintEvent*);
+protected:
+ void mouseReleaseEvent(QMouseEvent*);
+signals:
+ void imageClicked();
+};
+
+#endif