Skip to content

Commit d3545eb

Browse files
committed
stillstrip options
1 parent 160adc2 commit d3545eb

File tree

4 files changed

+157
-17
lines changed

4 files changed

+157
-17
lines changed

SlitScanGenerator/mainwindow.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ MainWindow::MainWindow(QWidget *parent) :
6464

6565
ui->spinWavelength->setValue(m_settings.value("lastFilterWavelength", 5).toDouble());
6666
ui->spinFilterDelta->setValue(m_settings.value("lastFilterDelta", 0.5).toDouble());
67+
ui->spinStillGap->setValue(m_settings.value("lastStillGap", 5).toDouble());
68+
ui->spinStillBorder->setValue(m_settings.value("lastStillBorder", 5).toDouble());
69+
ui->spinStillLineWidth->setValue(m_settings.value("lastStillLineWidth", 0.2).toDouble());
6770
ui->spinStillCount->setValue(m_settings.value("lastStillCount", 5).toInt());
6871
ui->spinStillDelta->setValue(m_settings.value("lastStillDelta", 60).toInt());
6972
ui->chkStillStrip->setChecked(m_settings.value("lastStillStrip", true).toBool());
@@ -82,7 +85,9 @@ MainWindow::~MainWindow()
8285
m_settings.setValue("lastStillSeparateFiles", ui->chkStillDeparateFile->isChecked());
8386
m_settings.setValue("lastFilterWavelength", ui->spinWavelength->value());
8487
m_settings.setValue("lastFilterDelta", ui->spinFilterDelta->value());
85-
88+
m_settings.setValue("lastStillGap", ui->spinStillGap->value());
89+
m_settings.setValue("lastStillBorder", ui->spinStillBorder->value());
90+
m_settings.setValue("lastStillLineWidth", ui->spinStillLineWidth->value());
8691
delete ui;
8792
}
8893

@@ -96,6 +101,9 @@ void MainWindow::saveINI()
96101
setall.setValue("stills/delta", ui->spinStillDelta->value());
97102
setall.setValue("stills/strip", ui->chkStillStrip->isChecked());
98103
setall.setValue("stills/separate_files", ui->chkStillDeparateFile->isChecked());
104+
setall.setValue("stills/gap", ui->spinStillGap->value());
105+
setall.setValue("stills/border", ui->spinStillBorder->value());
106+
setall.setValue("stills/line_width", ui->spinStillLineWidth->value());
99107
setall.setValue("normalize/enabled", ui->chkNormalize->isChecked());
100108
setall.setValue("normalize/x", ui->spinNormalizeX->value());
101109
setall.setValue("normalize/y", ui->spinNormalizeY->value());
@@ -116,12 +124,15 @@ void MainWindow::loadINI(const QString &fn, QString* vfn)
116124
ui->spinStillDelta->setValue(setall.value("stills/delta", ui->spinStillDelta->value()).toInt());
117125
ui->chkStillStrip->setChecked(setall.value("stills/strip", ui->chkStillStrip->isChecked()).toBool());
118126
ui->chkStillDeparateFile->setChecked(setall.value("stills/separate_files", ui->chkStillDeparateFile->isChecked()).toBool());
127+
ui->spinStillGap->setValue(setall.value("stills/gap", ui->spinStillGap->value()).toInt());
128+
ui->spinStillBorder->setValue(setall.value("stills/border", ui->spinStillBorder->value()).toInt());
129+
ui->spinStillLineWidth->setValue(setall.value("stills/line_width", ui->spinStillLineWidth->value()).toInt());
119130
ui->chkNormalize->setChecked(setall.value("normalize/enabled", ui->chkNormalize->isChecked()).toBool());
120131
ui->spinNormalizeX->setValue(setall.value("normalize/x", ui->spinNormalizeX->value()).toInt());
121132
ui->spinNormalizeY->setValue(setall.value("normalize/y", ui->spinNormalizeY->value()).toInt());
122133
ui->chkWavelength->setChecked(setall.value("filter/notch/enabled", ui->chkWavelength->isChecked()).toBool());
123134
ui->spinWavelength->setValue(setall.value("filter/notch/wavelength", ui->spinWavelength->value()).toDouble());
124-
ui->spinWavelength->setValue(setall.value("filter/notch/delta", ui->spinFilterDelta->value()).toDouble());
135+
ui->spinFilterDelta->setValue(setall.value("filter/notch/delta", ui->spinFilterDelta->value()).toDouble());
125136
}
126137
}
127138

@@ -171,7 +182,7 @@ void MainWindow::test()
171182
cimg_library::CImg<uint8_t> img;
172183
img.load_bmp(fn.toLocal8Bit().data());
173184
labXY->setPixmap(QPixmap::fromImage(CImgToQImage(img)));
174-
ProcessingTask::applyFilterNotch(img, QInputDialog::getInt(this, "TEST", "wavelength=", 10, 0,1000,2), 2);
185+
ProcessingTask::applyFilterNotch(img, QInputDialog::getInt(this, "TEST", "wavelength=", 10, 0,1000,2), 2, true);
175186
labYZ->setPixmap(QPixmap::fromImage(CImgToQImage(img)));
176187
}
177188
}
@@ -393,6 +404,9 @@ void MainWindow::processAll()
393404
task->stillDelta=ui->spinStillDelta->value();
394405
task->stillStrip=ui->chkStillStrip->isChecked();
395406
task->stillSeparateFiles=ui->chkStillDeparateFile->isChecked();
407+
task->stillGap=ui->spinStillGap->value();
408+
task->stillBorder=ui->spinStillBorder->value();
409+
task->stillLineWidth=ui->spinStillLineWidth->value();
396410

397411
task->normalize=ui->chkNormalize->isChecked();
398412
task->normalizeX=ui->spinNormalizeX->value();

SlitScanGenerator/mainwindow.ui

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@
7070
<property name="widgetResizable">
7171
<bool>true</bool>
7272
</property>
73+
<property name="alignment">
74+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
75+
</property>
7376
</widget>
7477
</item>
7578
<item row="5" column="1">
7679
<widget class="QTabWidget" name="tabWidget">
7780
<property name="currentIndex">
78-
<number>0</number>
81+
<number>1</number>
7982
</property>
8083
<widget class="QWidget" name="widProps">
8184
<attribute name="title">
@@ -241,6 +244,81 @@
241244
</property>
242245
</widget>
243246
</item>
247+
<item row="4" column="0">
248+
<widget class="QLabel" name="label_12">
249+
<property name="text">
250+
<string>gap between stills in strip:</string>
251+
</property>
252+
</widget>
253+
</item>
254+
<item row="4" column="1">
255+
<widget class="QDoubleSpinBox" name="spinStillGap">
256+
<property name="suffix">
257+
<string> % of height</string>
258+
</property>
259+
<property name="decimals">
260+
<number>1</number>
261+
</property>
262+
<property name="maximum">
263+
<double>100.000000000000000</double>
264+
</property>
265+
<property name="value">
266+
<double>5.000000000000000</double>
267+
</property>
268+
</widget>
269+
</item>
270+
<item row="5" column="0">
271+
<widget class="QLabel" name="label_13">
272+
<property name="text">
273+
<string>border around stills in strip:</string>
274+
</property>
275+
</widget>
276+
</item>
277+
<item row="5" column="1">
278+
<widget class="QDoubleSpinBox" name="spinStillBorder">
279+
<property name="suffix">
280+
<string> % of width</string>
281+
</property>
282+
<property name="decimals">
283+
<number>1</number>
284+
</property>
285+
<property name="maximum">
286+
<double>100.000000000000000</double>
287+
</property>
288+
<property name="value">
289+
<double>5.000000000000000</double>
290+
</property>
291+
</widget>
292+
</item>
293+
<item row="6" column="0">
294+
<widget class="QLabel" name="label_14">
295+
<property name="text">
296+
<string>still marker line width:</string>
297+
</property>
298+
</widget>
299+
</item>
300+
<item row="6" column="1">
301+
<widget class="QDoubleSpinBox" name="spinStillLineWidth">
302+
<property name="suffix">
303+
<string> % of width</string>
304+
</property>
305+
<property name="decimals">
306+
<number>1</number>
307+
</property>
308+
<property name="minimum">
309+
<double>0.000000000000000</double>
310+
</property>
311+
<property name="maximum">
312+
<double>100.000000000000000</double>
313+
</property>
314+
<property name="singleStep">
315+
<double>0.050000000000000</double>
316+
</property>
317+
<property name="value">
318+
<double>0.100000000000000</double>
319+
</property>
320+
</widget>
321+
</item>
244322
</layout>
245323
</widget>
246324
<widget class="QWidget" name="tab">
@@ -337,14 +415,17 @@
337415
<item>
338416
<widget class="QDoubleSpinBox" name="spinWavelength">
339417
<property name="decimals">
340-
<number>1</number>
418+
<number>2</number>
341419
</property>
342420
<property name="minimum">
343421
<double>1.000000000000000</double>
344422
</property>
345423
<property name="maximum">
346424
<double>10000.000000000000000</double>
347425
</property>
426+
<property name="singleStep">
427+
<double>0.100000000000000</double>
428+
</property>
348429
</widget>
349430
</item>
350431
<item>
@@ -365,6 +446,9 @@
365446
<property name="maximum">
366447
<double>10000.000000000000000</double>
367448
</property>
449+
<property name="singleStep">
450+
<double>0.020000000000000</double>
451+
</property>
368452
<property name="value">
369453
<double>0.100000000000000</double>
370454
</property>
@@ -389,13 +473,19 @@
389473
<property name="widgetResizable">
390474
<bool>true</bool>
391475
</property>
476+
<property name="alignment">
477+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
478+
</property>
392479
</widget>
393480
</item>
394481
<item row="5" column="0">
395482
<widget class="QScrollArea" name="scrollXZ">
396483
<property name="widgetResizable">
397484
<bool>true</bool>
398485
</property>
486+
<property name="alignment">
487+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
488+
</property>
399489
</widget>
400490
</item>
401491
<item row="2" column="0" colspan="2">

SlitScanGenerator/processingtask.cpp

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
4444
setall.setValue("stills/delta", stillDelta);
4545
setall.setValue("stills/strip", stillStrip);
4646
setall.setValue("stills/separate_files", stillSeparateFiles);
47+
setall.setValue("stills/gap", stillGap);
48+
setall.setValue("stills/border", stillBorder);
49+
setall.setValue("stills/line_width", stillLineWidth);
4750

4851
setall.setValue("normalize/enabled", normalize);
4952
setall.setValue("normalize/x", normalizeX);
@@ -68,6 +71,8 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
6871
std::string err;
6972
vid=openFFMPEGVideo(filename.toStdString(), &err);
7073
if (vid && readFFMPEGFrame(frame, vid)) {
74+
int still_b=stillBorder/100.0*frame.width();
75+
int still_g=stillGap/100.0*frame.height();
7176
maxProg=pis.size()+2+getFrameCount(vid);
7277
prog=1;
7378
int j=0;
@@ -89,7 +94,7 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
8994
setall.setValue(QString("item%1/file").arg(j,3,10,QChar('0')), QFileInfo(allini).absoluteDir().relativeFilePath(QFileInfo(fn).absoluteFilePath()));
9095
if (stillStrip && stillCnt>0) {
9196
stillStripImg.push_back(cimg_library::CImg<uint8_t>());
92-
stillStripImg[j].resize(frame.width()+10, 5+(frame.height()+5)*stillCnt, 1, 3);
97+
stillStripImg[j].resize(frame.width()+2*still_b, still_b+(frame.height()+still_g)*stillCnt-still_g+still_b, 1, 3);
9398
}
9499
j++;
95100
}
@@ -103,11 +108,16 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
103108

104109
bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
105110
{
111+
106112
prog++;
107113
maxProg=pis.size()+2+getFrameCount(vid);
108114
if (!m_saving) {
109115
// process old frame
110116
message=QObject::tr("processing frame %1/%2 ...").arg(z+1).arg(outputFrames);
117+
int still_b=stillBorder/100.0*frame.width();
118+
int still_g=stillGap/100.0*frame.height();
119+
int stilllw=std::max<int>(1,stillLineWidth/100.0*frame.width());
120+
111121
for (int j=0; j<results.size(); j++) {
112122
ProcessingTask::ProcessingItem pi=pis[j];
113123
if (pi.mode==Mode::ZY && z<results[j].width()) {
@@ -131,9 +141,13 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
131141
auto frame_s=frame;
132142
const unsigned char color[] = { 255,0,0 };
133143
if (pi.mode==Mode::ZY && z<results[j].width()) {
134-
frame_s.draw_line(pi.location,0,pi.location,frame.height(), color);
144+
for (int x=pi.location-stilllw/2; x<pi.location-stilllw/2+stilllw; x++) {
145+
frame_s.draw_line(x,0,x,frame.height(), color);
146+
}
135147
} else if (pi.mode==Mode::XZ && z<results[j].height()) {
136-
frame_s.draw_line(0,pi.location,frame.width(),pi.location, color);
148+
for (int y=pi.location-stilllw/2; y<pi.location-stilllw/2+stilllw; y++) {
149+
frame_s.draw_line(0,y,frame.width(),y, color);
150+
}
137151
}
138152
if (stillSeparateFiles) {
139153
QFileInfo fi(filename);
@@ -143,9 +157,9 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
143157
}
144158
if (stillStrip) {
145159
cimg_forXY(frame,x,y) {
146-
stillStripImg[j](5+x,5+y+stills*(5+frame.height()),0,0)=frame_s(x,y,0,0);
147-
stillStripImg[j](5+x,5+y+stills*(5+frame.height()),0,1)=frame_s(x,y,0,1);
148-
stillStripImg[j](5+x,5+y+stills*(5+frame.height()),0,2)=frame_s(x,y,0,2);
160+
stillStripImg[j](still_b+x,still_b+y+stills*(still_g+frame.height()),0,0)=frame_s(x,y,0,0);
161+
stillStripImg[j](still_b+x,still_b+y+stills*(still_g+frame.height()),0,1)=frame_s(x,y,0,1);
162+
stillStripImg[j](still_b+x,still_b+y+stills*(still_g+frame.height()),0,2)=frame_s(x,y,0,2);
149163
}
150164
}
151165
}
@@ -199,6 +213,9 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
199213
set.setValue("stills/delta", stillDelta);
200214
set.setValue("stills/strip", stillStrip);
201215
set.setValue("stills/separate_files", stillSeparateFiles);
216+
set.setValue("stills/gap", stillGap);
217+
set.setValue("stills/border", stillBorder);
218+
set.setValue("stills/line_width", stillLineWidth);
202219
set.setValue("normalize/enabled", normalize);
203220
set.setValue("normalize/x", normalizeX);
204221
set.setValue("normalize/y", normalizeY);
@@ -270,26 +287,38 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
270287
int offy=(img.height()-imgrgb.height())/2;
271288

272289
unsigned char one[] = { 1 }, zero[] = { 0 };
273-
cimg_library::CImg<unsigned char> mask(img.width(),img.height(),1,1,1);
290+
cimg_library::CImg<float> mask(img.width(),img.height(),1,1,1);
274291
double kmin=1.0/double(center+delta);
275292
double kmax=1.0/double(center-delta);
276293

277294
cimg_forXY(mask,x,y) {
295+
const float kx=double(x-mask.width()/2)/double(mask.width());
296+
const float ky=double(y-mask.height()/2)/double(mask.height());
297+
const float kabs2=kx*kx+ky*ky;
298+
const float kabs=sqrt(kabs2);
278299
mask(x,y)=1;
279-
float kx=double(x-mask.width()/2)/double(mask.width());
280-
float ky=double(y-mask.height()/2)/double(mask.height());
281-
float kabs2=kx*kx+ky*ky;
282300
if (kabs2>=kmin*kmin && kabs2<=kmax*kmax) mask(x,y)=0;
301+
//else if (kabs<kmin) mask(x,y)=exp(-(kabs-kmin)*(kabs-kmin)/(2.0*2.0*2.0));
302+
//else if (kabs>kmax) mask(x,y)=exp(-(kmax-kabs)*(kmax-kabs)/(2.0*2.0*2.0));
303+
283304
}
305+
mask.blur(2,2,2,false);
284306
if (testoutput) {
285307
sprintf(fn, "testmask.bmp");
286308
mask.get_normalize(0,255).save_bmp(fn);
287309
}
288310

289311
cimg_forC(imgrgb, c) {
290312
img.fill(0);
291-
cimg_forXY(imgrgb,x,y) {
313+
/*cimg_forXY(imgrgb,x,y) {
292314
img(offx+x,offy+y)=imgrgb(x,y,0,c);
315+
}*/
316+
img=imgrgb.get_channel(c);
317+
uint8_t cMin,cMax;
318+
cMin=img.min_max(cMax);
319+
img.resize(nnx, nny,1,1,0,1,0.5,0.5);//double(offx)/double(nnx),double(offy)/double(nny));
320+
if (offx>0 || offy>0) {
321+
// reflective boundary
293322
}
294323
if (testoutput) {
295324
sprintf(fn, "c%d_testinput.bmp", int(c));
@@ -312,7 +341,7 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
312341

313342
cimg_library::CImgList<float> nF(F);
314343
cimglist_for(F,l) nF[l].mul(mask).shift(-img.width()/2,-img.height()/2,0,0,2);
315-
cimg_library::CImg<uint8_t> r = nF.FFT(true)[0].normalize(0,255);
344+
cimg_library::CImg<uint8_t> r = nF.FFT(true)[0].normalize(cMin,cMax);
316345
if (testoutput) {
317346
sprintf(fn, "c%d_testNF0.bmp", int(c));
318347
F[0].save_bmp(fn);
@@ -323,5 +352,9 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
323352
imgrgb(x,y,0,c)=r(x+offx,y+offy);
324353
}
325354
}
355+
if (testoutput) {
356+
sprintf(fn, "testoutput.bmp");
357+
imgrgb.save_bmp(fn);
358+
}
326359

327360
}

SlitScanGenerator/processingtask.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ struct ProcessingTask
2929
int stillDelta;
3030
bool stillStrip;
3131
bool stillSeparateFiles;
32+
double stillGap;
33+
double stillBorder;
34+
double stillLineWidth;
3235

3336
bool normalize;
3437
int normalizeX;

0 commit comments

Comments
 (0)