00001
00002 #ifndef vipl_filter_txx_
00003 #define vipl_filter_txx_
00004
00005
00006
00007 #include "vipl_filter.h"
00008 #include <vcl_iostream.h>
00009 #include <vcl_algorithm.h>
00010
00011 #ifdef VCL_VC
00012 #pragma warning( disable: 4390 )
00013 #endif
00014
00015 #if !VCL_STATIC_CONST_INIT_INT_NO_DEFN
00016 template <class ImgIn,class ImgOut,class DataIn,class DataOut,int Arity,class PixelItr>
00017 const VIPL_FILTER_STATE vipl_filter<ImgIn,ImgOut,DataIn,DataOut,Arity,PixelItr>::Not_Ready VCL_STATIC_CONST_INIT_INT_DEFN( 0 );
00018 template <class ImgIn,class ImgOut,class DataIn,class DataOut,int Arity,class PixelItr>
00019 const VIPL_FILTER_STATE vipl_filter<ImgIn,ImgOut,DataIn,DataOut,Arity,PixelItr>::Ready VCL_STATIC_CONST_INIT_INT_DEFN( 1 );
00020 template <class ImgIn,class ImgOut,class DataIn,class DataOut,int Arity,class PixelItr>
00021 const VIPL_FILTER_STATE vipl_filter<ImgIn,ImgOut,DataIn,DataOut,Arity,PixelItr>::Unchanged VCL_STATIC_CONST_INIT_INT_DEFN( 2 );
00022 template <class ImgIn,class ImgOut,class DataIn,class DataOut,int Arity,class PixelItr>
00023 const VIPL_FILTER_STATE vipl_filter<ImgIn,ImgOut,DataIn,DataOut,Arity,PixelItr>::Filter_Owned VCL_STATIC_CONST_INIT_INT_DEFN( 4 );
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00036 vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00037 ::vipl_filter( ImgIn const* src_img ,
00038 ImgOut* dst_img ,
00039 int ninputs,
00040 int img_border ,
00041 DataOut fill_val )
00042 : hsimage_border_size(img_border),
00043 hsdef_fill_value( fill_val ),
00044 hsinput_state(Ready),
00045 hsfilter_state(Not_Ready),
00046 hsoutput_state(Not_Ready),
00047 hsnuminputs(ninputs),
00048 hsinf(vcl_vector<inimagept>(hsnuminputs)),
00049 hsoutf(dst_img),
00050 hssrc_section (0),
00051 hsinsecp (0),
00052 hsdst_section (0),
00053 hssecp (0),
00054 hsinROA (NULL),
00055 hsROA (NULL),
00056 hsis_input_driven(false)
00057 {
00058 #if 0
00059 for (int j = numinputs()-1; j>=0; --j)
00060 ref_inf()[j] = 0;
00061 #endif
00062 if (dst_img) {
00063 if (UNCHANGED(output_state()))
00064 put_output_state(output_state() ^ Unchanged);
00065 if (FILTER_OWNED(output_state())) {
00066 put_output_state(output_state() ^ Filter_Owned);
00067 #if 0
00068 if (READY(output_state())) FILTER_IMPTR_DEC_REFCOUNT(ref_outf());
00069 #endif
00070 }
00071 if (NOT_READY(output_state()))
00072 put_output_state(output_state() | Ready);
00073 #if 0
00074 FILTER_IMPTR_INC_REFCOUNT(dst_img);
00075 #endif
00076 }
00077 for (int i=0; i< ninputs; i++) {
00078 ref_inf()[i] = src_img;
00079 if (src_img) src_img++;
00080 #if 0
00081 if (ref_inf()[i]) FILTER_IMPTR_INC_REFCOUNT(((ImgIn*)ref_inf()[i]));
00082 #endif
00083 }
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00095 vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00096 ::vipl_filter( ImgIn const** src_img ,
00097 ImgOut* dst_img ,
00098 int ninputs,
00099 int img_border ,
00100 DataOut fill_val)
00101 : hsimage_border_size(img_border),
00102 hsdef_fill_value( fill_val ),
00103 hsinput_state(Ready),
00104 hsfilter_state(Not_Ready),
00105 hsoutput_state(Not_Ready),
00106 hsnuminputs(ninputs),
00107 hsinf(vcl_vector<inimagept>(hsnuminputs)),
00108 hsoutf(dst_img),
00109 hssrc_section (0),
00110 hsinsecp (0),
00111 hsdst_section (0),
00112 hssecp (0),
00113 hsinROA (NULL),
00114 hsROA (NULL),
00115 hsis_input_driven(false)
00116 {
00117 #if 0
00118 for (int j = numinputs()-1; j>=0; --j)
00119 ref_inf()[j] = 0;
00120 #endif
00121 if (dst_img) {
00122 if (UNCHANGED(output_state()))
00123 put_output_state(output_state() ^ Unchanged);
00124 if (FILTER_OWNED(output_state())) {
00125 put_output_state(output_state() ^ Filter_Owned);
00126 #if 0
00127 if (READY(output_state())) FILTER_IMPTR_DEC_REFCOUNT(ref_outf());
00128 #endif
00129 }
00130 if (NOT_READY(output_state()))
00131 put_output_state(output_state() | Ready);
00132 #if 0
00133 FILTER_IMPTR_INC_REFCOUNT(dst_img);
00134 #endif
00135 }
00136 for (int i=0; i< ninputs; i++, src_img++) {
00137 if (src_img == 0)
00138 vcl_cerr << "filter ctor passed vector will null src_img pointers, ignored them watch out.\n";
00139 else
00140 ref_inf()[i] = *src_img;
00141 #if 0
00142 if (ref_inf()[i]) FILTER_IMPTR_INC_REFCOUNT(((ImgIn*)ref_inf()[i]));
00143 #endif
00144 }
00145 }
00146
00147 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00148 vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00149 ::~vipl_filter()
00150 {
00151 #ifdef DEBUG
00152 vcl_cout << "destructor for abstract class filter called " << this << vcl_endl;
00153 #endif
00154 #ifndef SMARTPTR
00155 if (ref_src_section()) FILTER_IMPTR_DEC_REFCOUNT(ref_src_section());
00156 if (ref_dst_section()) FILTER_IMPTR_DEC_REFCOUNT(ref_dst_section());
00157 if (ref_secp()) FILTER_IMPTR_DEC_REFCOUNT(ref_secp());
00158 if (ref_insecp()) FILTER_IMPTR_DEC_REFCOUNT(ref_insecp());
00159 if (ref_ROA()) FILTER_IMPTR_DEC_REFCOUNT(ref_ROA());
00160 if (ref_inROA()) FILTER_IMPTR_DEC_REFCOUNT(ref_inROA());
00161 #if 0
00162 for (int i=0; i< numinputs(); i++) {
00163 if (ref_inf()[i]) {
00164 FILTER_IMPTR_DEC_REFCOUNT(
00165
00166 *((ImgIn**)(ref_inf())+i));
00167 }
00168 }
00169
00170 if (ref_inf()) {
00171 delete [] ref_inf();
00172
00173 ref_inf() = 0;
00174 }
00175
00176 #if 0
00177 if (FILTER_OWNED(hsoutput_state) && hsoutf)
00178 #else
00179 if (ref_outf())
00180 #endif
00181 {
00182 FILTER_IMPTR_DEC_REFCOUNT(ref_outf());
00183 }
00184 #endif
00185 #endif
00186 }
00187
00188 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00189 vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00190 ::vipl_filter()
00191 : hsimage_border_size(0),
00192 hsinput_state(Not_Ready),
00193 hsfilter_state(Not_Ready),
00194 hsoutput_state(Not_Ready),
00195 hsnuminputs(1),
00196 hsinf(vcl_vector<inimagept>(hsnuminputs)),
00197 hsoutf(0),
00198 hssrc_section(0),
00199 hsinsecp(0),
00200 hsdst_section(0),
00201 hssecp(0),
00202 hsinROA (NULL),
00203 hsROA (NULL),
00204 hsis_input_driven(false)
00205 {
00206 #if 0
00207 for (int i = 0; i < numinputs(); i++)
00208 ref_inf()[i] = 0;
00209 #endif
00210 }
00211
00212 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00213 vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00214 ::vipl_filter(vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr > const& t)
00215 : vipl_filter_abs (t),
00216 hsimage_border_size(t.hsimage_border_size),
00217 hsdef_fill_value(t.hsdef_fill_value),
00218 hsinput_state(t.hsinput_state),
00219 hsfilter_state(t.hsfilter_state),
00220 hsoutput_state(t.hsoutput_state),
00221 hsnuminputs(t.hsnuminputs),
00222 hsinf(vcl_vector<inimagept>(hsnuminputs)),
00223 hsoutf(0),
00224 hssrc_section(t.hssrc_section),
00225 hsinsecp(t.hsinsecp),
00226 hsdst_section(t.hsdst_section),
00227 hssecp(t.hssecp),
00228 hsinROA (t.hsinROA),
00229 hsROA (t.hsROA),
00230 hsis_input_driven(t.hsis_input_driven)
00231
00232 {
00233
00234
00235
00236
00237
00238
00239 for (int i = 0; i < numinputs(); i++) {
00240 ref_inf()[i] = t.inf()[i];
00241 #if 0
00242 if (ref_inf()[i]) FILTER_IMPTR_INC_REFCOUNT(((ImgIn*)ref_inf()[i]));
00243 #endif
00244 }
00245 #ifndef SMARTPTR
00246 if (ref_outf()) { FILTER_IMPTR_INC_REFCOUNT(ref_outf()); }
00247 if (ref_src_section()) { FILTER_IMPTR_INC_REFCOUNT(ref_src_section()); }
00248 if (ref_dst_section()) { FILTER_IMPTR_INC_REFCOUNT(ref_dst_section()); }
00249 if (ref_secp()) { FILTER_IMPTR_INC_REFCOUNT(ref_secp()); }
00250 if (ref_insecp()) { FILTER_IMPTR_INC_REFCOUNT(ref_insecp()); }
00251 if (ref_ROA()) { FILTER_IMPTR_INC_REFCOUNT(ref_ROA()); }
00252 if (ref_inROA()) { FILTER_IMPTR_INC_REFCOUNT(ref_inROA()); }
00253 #endif
00254
00255 if (FILTER_OWNED(hsoutput_state))
00256 hsoutput_state ^= Filter_Owned;
00257 }
00258
00259
00260
00261
00262
00263 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00264 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00265 ::is_section_within_ROA(int axis) const
00266 {
00267 if (is_input_driven()) {
00268 if (!inROA())
00269
00270 return true;
00271
00272 if (insecp()) {
00273 for (int i =0; i < Arity; i++){
00274 if ((insecp()->curr_sec_start(axis) > inROA()->curr_sec_end(axis)) ||
00275 (insecp()->curr_sec_end(axis) < inROA()->curr_sec_start(axis)))
00276 return false;
00277 }
00278 return true;
00279
00280 }
00281 }
00282 else {
00283
00284 if (!ROA())
00285 return true;
00286
00287 if (secp()) {
00288 for (int i =0; i < Arity; i++) {
00289 if ((secp()->curr_sec_start(axis) > ROA()->curr_sec_end(axis)) ||
00290 (secp()->curr_sec_end(axis) < ROA()->curr_sec_start(axis)))
00291 return false;
00292 }
00293 return true;
00294
00295 }
00296 }
00297
00298 vcl_cerr << "Warning: called is_section_within_ROA but no valid sections defined. Returning 0\n";
00299 return 0;
00300 }
00301
00302
00303
00304
00305
00306
00307 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00308 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00309 ::start(int axis) const
00310 {
00311 if (is_input_driven()) return start_src(axis);
00312 else return start_dst(axis);
00313 }
00314
00315
00316
00317
00318
00319
00320 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00321 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00322 ::start_src(int axis) const
00323 {
00324 if (insecp()){
00325 int ibs = image_border_size();
00326 int end = insecp()->curr_sec_end(axis);
00327 int st = insecp()->curr_sec_start(axis);
00328 if (st > end){
00329 int temp = end; end = st; st = temp;
00330 }
00331 st += ibs;
00332 end -= ibs;
00333 if (inROA())
00334 st =vcl_min(end,vcl_max(st,inROA()->curr_sec_start(axis)+ibs));
00335 #ifdef DEBUG
00336 vcl_cerr << "i_ [" << axis << "] st=" << st << " ibs=" << ibs << vcl_endl;
00337 #endif
00338 return st;
00339 }
00340
00341
00342 vcl_cerr << "Warning: called start_src but no valid sections defined. Returning 0\n";
00343 return 0;
00344 }
00345
00346
00347
00348
00349
00350
00351
00352 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00353 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00354 ::start_dst(int axis) const
00355 {
00356
00357 if (secp()){
00358 int ibs = image_border_size();
00359 int end = secp()->curr_sec_end(axis);
00360 int st = secp()->curr_sec_start(axis);
00361 if (st > end){
00362 int temp = end; end = st; st = temp;
00363 }
00364 st += ibs;
00365 end -= ibs;
00366 if (ROA())
00367 st = vcl_min(end,vcl_max(st,ROA()->curr_sec_start(axis)+ibs));
00368 #ifdef DEBUG
00369 vcl_cerr << "o_ [" << axis << "] st=" << st << " ibs=" << ibs << vcl_endl;
00370 #endif
00371 return st;
00372 }
00373
00374
00375 vcl_cerr << "Warning: called start_dst but no valid sections defined. Returning 0\n";
00376 return 0;
00377 }
00378
00379 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00380 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00381 ::start(int axis, int ) const
00382 { return start(axis); }
00383
00384
00385
00386
00387
00388
00389 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00390 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00391 ::stop(int axis) const
00392 {
00393 if (is_input_driven()) return stop_src(axis);
00394 else return stop_dst(axis);
00395 }
00396
00397
00398
00399
00400
00401
00402
00403 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00404 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00405 ::stop_src(int axis) const
00406 {
00407 if (insecp()){
00408 int ibs = image_border_size();
00409 int end = insecp()->curr_sec_end(axis);
00410 int st = insecp()->curr_sec_start(axis);
00411 if (st > end){
00412 end = st;
00413 }
00414 end -= ibs;
00415 #ifdef DEBUG
00416 vcl_cerr << "_i [" << axis << "] end=" << end << " ibs=" << ibs << vcl_endl;
00417 #endif
00418 return end;
00419 }
00420
00421
00422 vcl_cerr << "Warning: called stop_src but no valid sections defined. Returning 0\n";
00423 return 0;
00424 }
00425
00426
00427
00428
00429
00430
00431
00432 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00433 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00434 ::stop_dst(int axis) const
00435 {
00436
00437 if (secp()){
00438 int ibs = image_border_size();
00439 int end = secp()->curr_sec_end(axis);
00440 int st = secp()->curr_sec_start(axis);
00441 if (st > end){
00442 end = st;
00443 }
00444 end -= ibs;
00445 #ifdef DEBUG
00446 vcl_cerr << "_o [" << axis << "] end=" << end << " ibs=" << ibs << vcl_endl;
00447 #endif
00448 return end;
00449 }
00450
00451
00452 vcl_cerr << "Warning: called stop_dst but no valid sections defined. Returning 0\n";
00453 return 0;
00454 }
00455
00456 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00457 int vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00458 ::stop(int axis, int ) const
00459 { return stop(axis); }
00460
00461
00462
00463
00464 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00465 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00466 ::put_in_data_ptr(ImgIn const* fpointer , int index)
00467 {
00468 if (UNCHANGED(input_state()) || NOT_READY(input_state()))
00469 ref_input_state() = Ready;
00470 if ( 0 <= index && index < numinputs()) {
00471 #if 0
00472 if (ref_inf()[index]) {
00473
00474 FILTER_IMPTR_DEC_REFCOUNT(*((ImgIn**)(ref_inf())+index));
00475 }
00476 #endif
00477 ref_inf()[index] = fpointer;
00478 #if 0
00479 if (fpointer) FILTER_IMPTR_INC_REFCOUNT(((ImgIn*)fpointer));
00480 #endif
00481 return true;
00482 }
00483
00484 vcl_cerr << "Warning: index out of range in put_in_data_ptr, ignored\n";
00485 return false;
00486 }
00487
00488
00489
00490 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00491 ImgIn const* vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00492 ::in_data_ptr(int index)
00493 {
00494 if (index < 0 || index >= numinputs()) {
00495 vcl_cerr << "Warning: index " << index << " out of range, returning data at 0 instead\n";
00496 index = 0;
00497 }
00498 return inf()[index];
00499 }
00500
00501
00502
00503 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00504 const ImgIn& vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr>
00505 ::in_data(int index) const
00506 {
00507 if (0 <= index && index < numinputs()) {
00508 if (inf()[index])
00509 return *inf()[index];
00510 else {
00511 vcl_cerr << "Warning: input pointer is null returning image at index 0\n";
00512 return *inf()[0];
00513 }
00514 }
00515 vcl_cerr << "Warning: out of range is null, a new val, it will leak\n";
00516 return *inf()[0];
00517 }
00518
00519
00520
00521 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00522 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00523 ::put_out_data_ptr(ImgOut* fpointer , int )
00524 {
00525 if (UNCHANGED(output_state())) put_output_state(output_state() ^ Unchanged);
00526 if (FILTER_OWNED(output_state())) put_output_state(output_state() ^ Filter_Owned);
00527 #if 0
00528 if (ref_outf()) FILTER_IMPTR_DEC_REFCOUNT(ref_outf());
00529 #endif
00530 if (NOT_READY(output_state())) put_output_state(output_state() | Ready);
00531 #if 0
00532 FILTER_IMPTR_INC_REFCOUNT(fpointer);
00533 #endif
00534 put_outf(fpointer);
00535 return true;
00536 }
00537
00538
00539
00540 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00541 ImgOut* vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00542 ::out_data_ptr(int )
00543 {
00544 if (READY(output_state()) || UNCHANGED(output_state()))
00545 put_output_state(output_state() ^ Unchanged);
00546 if (READY(output_state()) )
00547 return ref_outf();
00548 else {
00549 vcl_cerr << "Warning: Tried to reference a NOT READY output-data, returned 0\n";
00550 return 0;
00551 }
00552 }
00553
00554
00555 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00556 ImgOut& vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr>
00557 ::out_data(int ) const
00558 {
00559 if (READY(output_state()) )
00560 return *outf();
00561 else {
00562 vcl_cerr << "Warning: Tried to reference a NOT READY output-returning old input, may coredump\n";
00563 return *outf();
00564 }
00565 }
00566
00567
00568
00569 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00570 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00571 ::preop()
00572 {
00573 return true;
00574 }
00575
00576
00577
00578 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00579 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00580 ::postop()
00581 {
00582 return true;
00583 }
00584
00585
00586
00587
00588 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00589 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00590 ::section_preop()
00591 {
00592 return true;
00593 }
00594
00595
00596
00597 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00598 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00599 ::section_postop()
00600 {
00601 return true;
00602 }
00603
00604
00605
00606
00607
00608 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00609 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00610 ::ptr_based_section_applyop()
00611 {
00612 return section_applyop();
00613 }
00614
00615
00616
00617
00618
00619
00620
00621
00622 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00623 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00624 ::filter()
00625 {
00626 bool proceed_anyway = false;
00627 if (NOT_READY(input_state())) {
00628
00629 ref_filter_state() = Not_Ready;
00630 vcl_cerr << "Warning: filtering without valid input\n";
00631 return false;
00632 }
00633 else if (UNCHANGED(input_state())) {
00634 ref_filter_state() |= Unchanged;
00635 }
00636 else
00637 ref_filter_state() |= Ready;
00638 if (NOT_READY(output_state()) || (FILTER_OWNED(output_state()) &&
00639 CHANGED(input_state()))) {
00640
00641
00642 #if 0
00643 if (outf()) FILTER_IMPTR_DEC_REFCOUNT(ref_outf());
00644 #endif
00645 vcl_cerr << "Warning: Input changed after output set. Sizes may not match...\n";
00646 }
00647 if ((check_params_1(proceed_anyway) &&
00648 READY(filter_state()) && CHANGED(filter_state())) || proceed_anyway) {
00649 return applyop();
00650 }
00651 return proceed_anyway;
00652 }
00653
00654 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00655 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00656 ::is_ready() const
00657 {
00658 bool proceeding=false;
00659 return check_params_1(proceeding) && !proceeding;
00660 }
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00672 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00673 ::process( ImgIn const& inimg, ImgOut& outimg)
00674 {
00675 put_in_data_ptr(&inimg);
00676 put_out_data_ptr(&outimg);
00677 bool ret = filter();
00678 put_in_data_ptr(0);
00679 put_out_data_ptr(0);
00680 return ret;
00681 }
00682
00683
00684 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00685 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00686 ::process( ImgIn const* inimg, ImgOut* outimg)
00687 {
00688 put_in_data_ptr(inimg);
00689 put_out_data_ptr(outimg);
00690 bool ret = filter();
00691 put_in_data_ptr(0);
00692 put_out_data_ptr(0);
00693 return ret;
00694 }
00695
00696
00697
00698
00699
00700 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00701 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00702 ::check_params_1( bool& proceed_on_warn) const
00703 {
00704 proceed_on_warn = true;
00705
00706 return !NOT_READY(output_state()) && !NOT_READY(input_state());
00707 }
00708
00709 #ifdef USE_COMPOSE_WITH
00710
00711
00712
00713
00714
00715
00716 template < class ImgIn, class ImgOut, class DataIn, class DataOut, int Arity, class PixelItr>
00717 bool vipl_filter< ImgIn, ImgOut, DataIn, DataOut, Arity, PixelItr >
00718 ::compose_with(vipl_filter_abs& to)
00719 {
00720 vcl_cerr << "Warning: called unimplemented method compose_with\n";
00721 return false;
00722 }
00723 #endif
00724
00725 #endif // vipl_filter_txx_