Skip to content

Commit a7832ba

Browse files
committed
Version 1.6 beta. Fixed zernike bug and made other changes, See
revhistory.
1 parent 6001428 commit a7832ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7736
-367
lines changed

DFTFringe.pro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TARGET = DFTFringe
2222
TEMPLATE = app
2323

2424
CONFIG += ``
25+
2526
SOURCES += main.cpp\
2627
mainwindow.cpp \
2728
igramarea.cpp \
@@ -147,7 +148,6 @@ HEADERS += mainwindow.h \
147148
statsview.h \
148149
jitteroutlinedlg.h \
149150
nullvariationdlg.h
150-
151151
FORMS += mainwindow.ui \
152152
dfttools.ui \
153153
dftarea.ui \
@@ -205,7 +205,6 @@ CONFIG( debug, debug|release ) {
205205
INCLUDEPATH += C:\\qwt-6.1.2\\src
206206

207207

208-
209208
INCLUDEPATH += c:\opencv\build\include
210209
LIBS += C:/opencv/build-mingw/bin/*.dll
211210

@@ -220,7 +219,7 @@ RC_FILE = DFTFringe.rc
220219

221220

222221
# The application version
223-
VERSION = 1.4
222+
VERSION = 1.6
224223

225224
# Define the preprocessor macro to get the application version in our application.
226225
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

RevisionHistory.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@
3636

3737

3838
</ul></ul>
39+
<ul><li>Version 1.6-beta</li>
40+
<ul><li>Corrected zernike calculating bug introduced in vers 1.2 Should give reliable results once again.</li>
41+
<li> Added software null error tolerance in view menu. </li>
42+
<li> Modified outline boundary slightly to eliminate fringes around mirror after DFT analysis.</li>
43+
<li> Added gamma (contrast) horizontal slider control to DFT tools.</li>
44+
<li> Corrected issues when several wavefronts are loaded and a change propigates thru all with the last one in the list
45+
displaying the correct metrics.Hopefully smoothing remains if enabled.</li>
46+
<li> Gaussian smoothing modified to not include data outise mirror outside board when calculating smoothing just inside the outline.</li>
47+
</ul></ul>
48+
49+
3950
<h3>Known bugs</h3>
4051
<p>Outline does not always appear on interferogram when processing in batch mode. Workaround is to rotate the mouse wheel to resize it
4152
when in Manual mode batch.</p>

contourview.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class contourView : public QWidget
3333
explicit contourView(QWidget *parent = 0, ContourTools *tools = 0);
3434
~contourView();
3535
ContourPlot *getPlot();
36+
bool zoomed;
3637
signals:
3738
void lineSpacingChanged(double);
3839
void showAllContours();
@@ -45,7 +46,7 @@ private slots:
4546

4647
private:
4748
Ui::contourView *ui;
48-
bool zoomed;
49+
4950
};
5051

5152
#endif // CONTOURVIEW_H

dftarea.cpp

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ cv::Mat makeMask(CircleOutline outside, CircleOutline center, cv::Mat data){
2929
int width = data.cols;
3030
int height = data.rows;
3131

32-
double radm = outside.m_radius+1; //Don't know why but +1 gives the best result match to the expected value.
32+
double radm = ceil(outside.m_radius);
3333
double rado = center.m_radius;
3434
double cx = outside.m_center.x();
3535
double cy = outside.m_center.y();
36-
cv::Mat mask = cv::Mat::zeros(height,width,CV_8UC1);
36+
cv::Mat mask = cv::Mat::ones(height,width,CV_8UC1);
3737
for (int y = 0; y < height; ++y){
3838
for (int x = 0; x < width; ++x){
3939
double dx = (double)(x - (cx))/(radm);
@@ -57,13 +57,14 @@ cv::Mat makeMask(CircleOutline outside, CircleOutline center, cv::Mat data){
5757
return mask;
5858
}
5959

60-
DFTArea::DFTArea(QWidget *parent, IgramArea *ip, DFTTools * tools, vortexDebug *vdbug) :
61-
QWidget(parent),m_size(640), tools(tools),
60+
DFTArea::DFTArea(QWidget *mparent, IgramArea *ip, DFTTools * tools, vortexDebug *vdbug) :
61+
QWidget(mparent),m_size(640), tools(tools),
6262
dftSizeStr("640 X 640"), m_center_filter(10.),ui(new Ui::DFTArea),igramArea(ip),m_smooth(9.),
6363
m_vortexDebugTool(vdbug)
6464

6565
{
6666
ui->setupUi(this);
67+
m_gamma = 2.5;
6768
connect(tools,SIGNAL(dftChannel(const QString&)), this, SLOT(setChannel(const QString&)));
6869
connect(tools,SIGNAL(dftSizeChanged(const QString&)), this, SLOT(dftSizeChanged(const QString&)));
6970
connect(tools,SIGNAL(dftSizeVal(int)), this, SLOT(dftSizeVal(int)));
@@ -155,22 +156,20 @@ Mat DFTArea::grayComplexMatfromImage(QImage &img){
155156
double centerY = igramArea->m_outside.m_center.y();
156157
double rad = igramArea->m_outside.m_radius;
157158
double radpix = ceil(rad);
158-
double left = centerX - radpix;
159-
double top = centerY - radpix;
159+
int border = 10;
160+
double left = floor((centerX - radpix - border));
161+
double top = floor(centerY - radpix - border);
160162
vector<Mat > bgr_planes;
161163
top = max(top,0.);
162164
left = max(left,0.);
163-
int width = 2. * (radpix);
165+
int width = ceil(2. * (radpix) + 2 * border);
164166
width = min(width, img.width());
165167

166168
// new center because of crop
167169
double xCenterShift = centerX - left;
168170
double yCenterShift = centerY - top;
169171

170172
cv::Mat iMat(img.height(), img.width(), CV_8UC4, img.bits(), img.bytesPerLine());
171-
cv::Mat tmp = iMat.clone();
172-
173-
174173
cv::Mat roi = iMat(cv::Rect((int)left,(int)top,(int)width,(int)width)).clone();
175174

176175
double centerDx = centerX - igramArea->m_center.m_center.x();
@@ -187,7 +186,7 @@ Mat DFTArea::grayComplexMatfromImage(QImage &img){
187186
if (scaleFactor < 1.){
188187

189188
cv::resize(roi,roi, cv::Size(0,0), scaleFactor, scaleFactor);
190-
double roic = roi.rows/2.;
189+
double roic = (roi.rows-1)/2.;
191190
m_outside = CircleOutline(QPointF(roic,roic),roic);
192191
m_center = CircleOutline(QPointF((roic - centerDx * scaleFactor), (roic - centerDy * scaleFactor)),
193192
m_center.m_radius * scaleFactor);
@@ -205,6 +204,7 @@ Mat DFTArea::grayComplexMatfromImage(QImage &img){
205204

206205
split( roi, bgr_planes );
207206

207+
208208
cv::Scalar mean;
209209
mean = cv::mean(roi);
210210
double maxMean = 0;
@@ -224,32 +224,47 @@ Mat DFTArea::grayComplexMatfromImage(QImage &img){
224224
else if (channel == "Green") maxndx = 1;
225225
else if (channel == "Red") maxndx = 2;
226226
qDebug() << "Max channel " << maxndx;
227+
Mat padded = bgr_planes[maxndx].clone();
227228

228-
Mat padded; //expand input image to optimal size
229229
int m = getOptimalDFTSize( roi.rows ) - roi.rows;
230230
int n = getOptimalDFTSize( roi.cols ) - roi.cols; // on the border add zero values
231-
m =0;
231+
// disabled adding optomizing DFT boarder.
232+
m = 0;
232233
n = 0;
233234
qDebug() << "pady " << m << " padx " << n;
234235
if (m > 0 || n > 0)
235-
copyMakeBorder(bgr_planes[maxndx], padded, 0, m, 0, n, BORDER_CONSTANT, Scalar::all(0));
236-
else
237-
padded = bgr_planes[maxndx].clone();
236+
copyMakeBorder(padded, padded, 0, m, 0, n, BORDER_CONSTANT, Scalar::all(mean[maxndx]));
237+
238238
padded = padded - mean[maxndx];
239-
// disabled adding optomizing DFT boarder.
239+
240240
Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
241241

242-
m_mask = makeMask(m_outside,m_center,*planes);
243-
if (Settings2::showMask())
244-
showData("Mask", m_mask);
242+
m_mask = makeMask(m_outside,m_center, *planes);
243+
if (Settings2::showMask()){
244+
Mat tmp = planes[0].clone();
245+
normalize(tmp, tmp,0,255,CV_MINMAX);
246+
tmp.convertTo(tmp,CV_8U);
247+
Mat mm;
248+
Mat channels[3];
249+
250+
channels[1] = m_mask;
251+
channels[2] = tmp;
252+
channels[0] = m_mask;
253+
merge(channels,3,mm);
254+
for (int i = 0; i < 3; ++i){
255+
//imshow(QString().number(i).toStdString().c_str(),channels[i]);
256+
}
257+
imshow("mm", mm);
258+
waitKey(1);
259+
260+
}
245261
cv::Mat tmpMask;
246262

247263
planes[0].copyTo(tmpMask,m_mask); // Convert image to binary
248264
planes[0] = tmpMask.clone();
249265
mean = cv::mean(planes[0],m_mask);
250266
planes[0] -= mean;
251-
//matDisplay md(planes[0],mean[0]);
252-
//md.exec();
267+
253268
Mat complexI;
254269
merge(planes, 2, complexI); // Add to the expanded another plane with zeros
255270
return complexI;
@@ -346,26 +361,40 @@ void DFTArea::doDFT(){
346361
cv::Mat realImage;
347362
dft(complexI,realImage,DFT_INVERSE);
348363
split(realImage,planes);
349-
//cv::imshow("Inverse", planes[0]/(planes[0].cols * planes[0].rows));
350-
//cv::waitKey(1);
364+
351365
shiftDFT(complexI);
352366
m_dft = complexI/complexI.size().area();
353367

354-
magIImage = showMag(complexI);
368+
magIImage = showMag(complexI,false,"", true, m_gamma);
369+
scale = 1.;
370+
double h = magIImage.height();
371+
qDebug() <<" dft size "<< size();
372+
scale = double(parentWidget()->size().height())/h;
373+
if (scale < 1.)
374+
scale = 1.;
375+
magIImage = magIImage.scaled(magIImage.width() * scale, magIImage.height() * scale);
376+
setMinimumSize(magIImage.size());
355377

356378
//emit selectDFTTab();
357379
update();
358380
if (Settings2::showDFT())
359381
emit dftReady(magIImage); //Creates a thumbnail dft area
360382
}
383+
void DFTArea::gamma(int i){
384+
double v = 1. + 5. * (double)i/99.;
385+
m_gamma = v;
386+
doDFT();
387+
}
388+
361389
void DFTArea::paintEvent(QPaintEvent *)
362390
{
363391
QPainter painter(this);
364392
painter.drawImage(QPoint(0,0),magIImage);
365393
painter.setBrush(QColor(0,0,100,50));
366-
painter.drawEllipse(QPointF(magIImage.width()/2,magIImage.height()/2), m_center_filter,m_center_filter);
394+
painter.drawEllipse(QPointF(magIImage.width()/2,magIImage.height()/2),
395+
scale * m_center_filter,scale * m_center_filter);
367396
if (m_center_filter > 0.) {
368-
double val = (double)m_center_filter;
397+
double val = (double)m_center_filter * scale;
369398
val *= val;
370399
int last = 0;
371400
for (int i = 0; i < magIImage.width()-1; ++i){
@@ -379,13 +408,7 @@ void DFTArea::paintEvent(QPaintEvent *)
379408
}
380409
}
381410
}
382-
void DFTArea::resizeIgram(){
383-
384-
}
385411

386-
void DFTArea::setFilter(double){
387-
388-
}
389412

390413
#define WRAP(x) (((x) > 0.5) ? ((x)-1.0) : (((x) <= -0.5) ? ((x)+1.0) : (x)))
391414
#define WRAPPI(x) (((x) > M_PI) ? ((x)-2*M_PI) : (((x) <= -M_PI) ? ((x)+2*M_PI) : (x)))
@@ -802,8 +825,8 @@ void DFTArea::makeSurface(){
802825
phase.size().width, phase.size().height);
803826

804827
flip(result,result,0); // flip around x axis.
805-
m_outside.m_center.ry() = wy - m_outside.m_center.y() - 1;
806-
m_center.m_center.ry() = wy - m_center.m_center.y() - 1;
828+
m_outside.m_center.ry() = result.rows - m_outside.m_center.y();
829+
m_center.m_center.ry() = result.rows - m_center.m_center.y();
807830
mirrorDlg *md = mirrorDlg::get_Instance();
808831
if (md->fringeSpacing != 1.){
809832
result *= md->fringeSpacing;
@@ -832,7 +855,7 @@ void DFTArea::mouseMoveEvent(QMouseEvent *event){
832855
int xcenter = (magIImage.width() -1)/2;
833856
int ycenter = (magIImage.height()-1)/2;
834857
int rad = sqrt(pow(pos.x()-xcenter,2)+pow(pos.y() - ycenter,2));
835-
emit updateFilterSize(rad);
858+
emit updateFilterSize(rad/scale);
836859
}
837860

838861
void DFTArea::mousePressEvent(QMouseEvent *event)
@@ -844,7 +867,7 @@ void DFTArea::mousePressEvent(QMouseEvent *event)
844867
int ycenter = (magIImage.height()-1)/2;
845868
int rad = sqrt(pow(Raw.x()-xcenter,2)+pow(Raw.y() - ycenter,2));
846869

847-
emit updateFilterSize(rad);
870+
emit updateFilterSize(rad/scale);
848871
capture = true;
849872
}
850873

dftarea.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ class DFTArea : public QWidget
5555
double low);
5656
public slots:
5757
void doDFT();
58-
void resizeIgram();
59-
void setFilter(double);
6058
void dftSizeChanged(const QString&);
6159
void dftSizeVal(int);
6260
void setChannel(const QString&);
6361
void dftCenterFilter(double v);
6462
void makeSurface();
6563
void newIgram(QImage);
64+
void gamma(int);
6665
signals:
6766
void setDftSizeVal(int);
6867
void selectDFTTab();
@@ -76,6 +75,7 @@ public slots:
7675
bool capture;
7776
CircleOutline m_outside;
7877
CircleOutline m_center;
78+
double m_gamma;
7979

8080
IgramArea *igramArea;
8181
void paintEvent(QPaintEvent *);
@@ -87,6 +87,7 @@ public slots:
8787
vortexDebug *m_vortexDebugTool;
8888
int m; // x border added to dft
8989
int n; //y border added to dft
90+
double scale;
9091
};
9192

9293

dftarea.ui

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<ui version="4.0">
2-
<author/>
3-
<comment/>
4-
<exportmacro/>
53
<class>DFTArea</class>
6-
<widget name="DFTArea" class="QWidget">
4+
<widget class="QWidget" name="DFTArea">
75
<property name="geometry">
86
<rect>
97
<x>0</x>
108
<y>0</y>
11-
<width>400</width>
12-
<height>300</height>
9+
<width>800</width>
10+
<height>800</height>
1311
</rect>
1412
</property>
13+
<property name="sizePolicy">
14+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
15+
<horstretch>1</horstretch>
16+
<verstretch>1</verstretch>
17+
</sizepolicy>
18+
</property>
1519
<property name="windowTitle">
1620
<string>Form</string>
1721
</property>
22+
<layout class="QVBoxLayout" name="verticalLayout"/>
1823
</widget>
19-
<pixmapfunction/>
24+
<resources/>
2025
<connections/>
2126
</ui>

dfttools.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ DFTTools::DFTTools(QWidget *parent) :
3434
}
3535
void DFTTools::connectTo(QWidget *view){
3636
connect(view, SIGNAL(updateFilterSize(int)),this, SLOT(setCenterFilterValue(int)));
37+
connect(ui->gammaSl, SIGNAL(valueChanged(int)), view, SLOT(gamma(int)));
3738
}
3839
DFTTools::~DFTTools()
3940
{
@@ -67,3 +68,5 @@ void DFTTools::on_computeDFT_pressed()
6768
{
6869
emit doDFT();
6970
}
71+
72+

dfttools.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class DFTTools : public QDockWidget
4141
void dftSizeVal(int);
4242
void dftCenterFilter(double);
4343
void makeSurface();
44-
44+
void enlarge(bool);
45+
void gamma(double);
4546

4647
private slots:
4748

@@ -53,6 +54,7 @@ private slots:
5354

5455
void on_computeDFT_pressed();
5556

57+
5658
private:
5759
Ui::DFTTools *ui;
5860
};

0 commit comments

Comments
 (0)