@@ -44,6 +44,9 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
44
44
setall.setValue (" stills/delta" , stillDelta);
45
45
setall.setValue (" stills/strip" , stillStrip);
46
46
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);
47
50
48
51
setall.setValue (" normalize/enabled" , normalize);
49
52
setall.setValue (" normalize/x" , normalizeX);
@@ -68,6 +71,8 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
68
71
std::string err;
69
72
vid=openFFMPEGVideo (filename.toStdString (), &err);
70
73
if (vid && readFFMPEGFrame (frame, vid)) {
74
+ int still_b=stillBorder/100.0 *frame.width ();
75
+ int still_g=stillGap/100.0 *frame.height ();
71
76
maxProg=pis.size ()+2 +getFrameCount (vid);
72
77
prog=1 ;
73
78
int j=0 ;
@@ -89,7 +94,7 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
89
94
setall.setValue (QString (" item%1/file" ).arg (j,3 ,10 ,QChar (' 0' )), QFileInfo (allini).absoluteDir ().relativeFilePath (QFileInfo (fn).absoluteFilePath ()));
90
95
if (stillStrip && stillCnt>0 ) {
91
96
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 );
93
98
}
94
99
j++;
95
100
}
@@ -103,11 +108,16 @@ bool ProcessingTask::processInit(int &prog, int &maxProg, QString &message, QStr
103
108
104
109
bool ProcessingTask::processStep (int &prog, int &maxProg, QString &message)
105
110
{
111
+
106
112
prog++;
107
113
maxProg=pis.size ()+2 +getFrameCount (vid);
108
114
if (!m_saving) {
109
115
// process old frame
110
116
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
+
111
121
for (int j=0 ; j<results.size (); j++) {
112
122
ProcessingTask::ProcessingItem pi=pis[j];
113
123
if (pi.mode ==Mode::ZY && z<results[j].width ()) {
@@ -131,9 +141,13 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
131
141
auto frame_s=frame;
132
142
const unsigned char color[] = { 255 ,0 ,0 };
133
143
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
+ }
135
147
} 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
+ }
137
151
}
138
152
if (stillSeparateFiles) {
139
153
QFileInfo fi (filename);
@@ -143,9 +157,9 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
143
157
}
144
158
if (stillStrip) {
145
159
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 );
149
163
}
150
164
}
151
165
}
@@ -199,6 +213,9 @@ bool ProcessingTask::processStep(int &prog, int &maxProg, QString &message)
199
213
set.setValue (" stills/delta" , stillDelta);
200
214
set.setValue (" stills/strip" , stillStrip);
201
215
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);
202
219
set.setValue (" normalize/enabled" , normalize);
203
220
set.setValue (" normalize/x" , normalizeX);
204
221
set.setValue (" normalize/y" , normalizeY);
@@ -270,26 +287,38 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
270
287
int offy=(img.height ()-imgrgb.height ())/2 ;
271
288
272
289
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 );
274
291
double kmin=1.0 /double (center+delta);
275
292
double kmax=1.0 /double (center-delta);
276
293
277
294
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);
278
299
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;
282
300
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
+
283
304
}
305
+ mask.blur (2 ,2 ,2 ,false );
284
306
if (testoutput) {
285
307
sprintf (fn, " testmask.bmp" );
286
308
mask.get_normalize (0 ,255 ).save_bmp (fn);
287
309
}
288
310
289
311
cimg_forC (imgrgb, c) {
290
312
img.fill (0 );
291
- cimg_forXY (imgrgb,x,y) {
313
+ /* cimg_forXY(imgrgb,x,y) {
292
314
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
293
322
}
294
323
if (testoutput) {
295
324
sprintf (fn, " c%d_testinput.bmp" , int (c));
@@ -312,7 +341,7 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
312
341
313
342
cimg_library::CImgList<float > nF (F);
314
343
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 );
316
345
if (testoutput) {
317
346
sprintf (fn, " c%d_testNF0.bmp" , int (c));
318
347
F[0 ].save_bmp (fn);
@@ -323,5 +352,9 @@ void ProcessingTask::applyFilterNotch(cimg_library::CImg<uint8_t> &imgrgb, doubl
323
352
imgrgb (x,y,0 ,c)=r (x+offx,y+offy);
324
353
}
325
354
}
355
+ if (testoutput) {
356
+ sprintf (fn, " testoutput.bmp" );
357
+ imgrgb.save_bmp (fn);
358
+ }
326
359
327
360
}
0 commit comments