///////////////////////////////////////////////////////////// //! rcsid="$Id: exIntlIter.cc,v 1.4 2000/11/24 17:17:05 ees1wc Exp $" #include "amma/Image.hh" #include "amma/ImgField.hh" #include "amma/FieldIter.hh" #include "amma/VideoIntl.hh" #include "amma/Video.hh" #include "amma/YUVValue.hh" #include "amma/ShiftReg.hh" #include "amma/Option.hh" #include "amma/Filename.hh" // Example of using field iterators to do temporal filtering. int main(int argc, char* argv[]) { OptionC opt(argc, argv); opt.Comment("Uses field iterators to do temporal filtering."); FilenameC ip_name (opt.String("", "", "I/p file")); FilenameC op_name (opt.String("", "", "O/p file")); opt.CompulsoryArgs(2); opt.Check(); VideoInC ipthing(ip_name); VideoIntlInC ip (ipthing); ShiftRegC > sr (3); VideoOutC opthing(op_name); VideoIntlOutC op (opthing); // Temporally filter an interlaced stream while (ip.FieldNo() <= 6) { ImgFieldC ipbuff(ip.Get()); sr.ShiftL(ipbuff); if (sr[0].IsValid()) { // shrink o/p by 1 pixel ImageRectangleC op_rect(ipbuff.Rectangle()); op_rect.Expand(-1); ImgFieldC filt(op_rect, sr[1]); for(FieldIterC it(filt);it.IsElm();it.Next()) { PixelC p(it.Pixel()); // weighted sum from 3 shift reg fields YUVValueC ans; ans = YUVValueC(sr[1][p])*4 + YUVValueC(sr[0][p.NUp()]) + YUVValueC(sr[0][p.NDown()]) + YUVValueC(sr[2][p.NUp()]) + YUVValueC(sr[2][p.NDown()]); ans /= 8; it.Data() = ans.Cut(); } cerr << "Current field: " << filt.FieldInFrame() << '\n'; op.Put(filt); } } return 0; }