1 / 32

Traditional Image Processing

Traditional Image Processing. Data Structures Images, Palettes , Histograms , Profiles , etc. For many datatypes (8bit, 16 bit , float , etc.) Algorithms Dependent on Data Structures Dependent on datatypes Combinatorial Explosion -> unmanageable

peigi
Télécharger la présentation

Traditional Image Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. www.ngi-central.org

  2. Traditional Image Processing • Data Structures • Images, Palettes, Histograms, Profiles, etc. • Formanydatatypes (8bit, 16 bit, float, etc.) • Algorithms • Dependent on Data Structures • Dependent on datatypes • Combinatorial Explosion -> unmanageable • Toimplementonenewalgorithm, it must bewrittenmanytimes – foreach type www.ngi-central.org

  3. Generic Image Processing • GenericProgrammingcomestotherescue • Threekey design techniques • Iteratorsdecoupledatastructures and algorithms • Functorsallowtoexchangepartsofcomputation • Genericalgorithms in termsofabstractiterators and functors • Enablingtechnologyofcompilersisthetemplate<> mechanism www.ngi-central.org

  4. Standard Template Library • STL is an implementationofgenericprogrammingconcepts • STL isavailablewith all compilerssinceitispartofthe C++ standard • STL isaround 10 yearsold and consideredmature • Educational material tolearngenericprogramming in generaland STL in particularisavailable www.ngi-central.org

  5. Example: RGB to Gray • Using STL style programming structRGBValue { unsignedcharred, green, blue; }; structRGBToGray { unsignedcharoperator()(constRGBValue& rgb) const { return 0.3*rgb.red + 0.59*rgb.green + 0.11*rgb.blue; } }; vector<RGBValue> rgb; vector<unsignedchar> gray; ... transform(rgb.begin(), rgb.end(), gray.begin(), RGBToGray()); www.ngi-central.org

  6. New:worksfor all types! Betterexample • Templated on thedatatype • <template class T> • struct RGBValue { • T red, green, blue; • }; • <template class T> • struct RGBToGray { • T operator()(const RGBValue<T>& rgb) const { • return 0.3*rgb.red + 0.59*rgb.green + 0.11*rgb.blue; • } • }; • vector<RGBValue<float> > rgb; • vector<float> gray; • ... • transform(rgb.begin(), rgb.end(), gray.begin(), RGBToGray<float>()); www.ngi-central.org

  7. STL leavesthingstodesire • STL isdesignedtoworkwith 1D data • Images areinherentlytwo(multi)dimensional • Somealgorithms do not needthedimensionality • Use STL in thiscase • Somealgorithmsneedthedimensionality • Cannotuse STL, needsomething different www.ngi-central.org

  8. Multidimensional Locators • A locatoris a multidimensional iterator • Logical extensionto an iterator Move theiterator ++it; --it; it+=100; it-=50; Move thelocator ++it.x; --it.y; it.x+=100; it.y-=50; www.ngi-central.org

  9. Algorithms change as well • // STL implementation • template<class IT, class F> • IT transform(IT First, IT Last, IT Dest, F Func) • { • for (; First != Last; ++First, ++Dest) • *Dest = Func(*First); • return (Dest); • } • // 2D implementation • template<class IT, class F> • IT transform(IT First, IT Last, IT Dest, F Func) • { • for (; First.y != Last.y; ++First.y, ++Dest.y) • for (; First.x != Last.x; ++First.x, ++Dest.x) • *Dest = Func(*First); • return (Dest); • } www.ngi-central.org

  10. What do wegain? • An algorithmliketransformreplacesmanyfunctions in traditional programming style • Itcan do this, becauseitistemplated on thefunction • We still needtoprogramthefunctionality, but decoupledfromnavigation • Itsavesustorewritetheloopsmanytimes • Bonus: thefunctionobjectscanbereused in completely different algorithmsas well • Itcan do this, becauseitistemplated on thedatatype (byiteratorindirection) • Itsavesustorewritethecompletethingforeachdatatype • The gainistremendous (time, functionality, flexibility) www.ngi-central.org

  11. NGI - Goals • Image Processing • Image -> Image • Image Analysis • Image -> Numbers • Generic Library • C++ • Templates • Source code • Independence of type • High Performance • nopenaltyforgenericcode • Portability • clean sourcecodefor easy portability www.ngi-central.org

  12. Directory Structure • Code (include/) • Third partycode (toolkits/) • Documentation (book/, reference/, presentations/) • Sample code (samples/) and sample images (images/) • Automated tests (tests/) www.ngi-central.org

  13. NGI - Tests • Unit Tests • Features of a class/functionaretested in isolation • Regression Tests • Outcomeof a functionistestedforregressions • Image/Text comparisons (now == previous) • Benchmarks • Measured in clocks per pixel www.ngi-central.org

  14. NGI - Documentation • User Documentation • NGI Book • Reference Documentation • BuiltwithDoxygenfromsourcecode (HTML) • Alwaysup-to-date www.ngi-central.org

  15. Third Party Code • Mandatory • boost (www.boost.org) • Optional • FreeImage (freeimage.sourceforge.net) • Cairo (www.cairographics.org) www.ngi-central.org

  16. NGI – Build System • CMakeisusedasbuildengine • modular • selectcompiler(VS2005, VS2008, VS2010, Intel) • runtests • builddocumentation • Currentlysettingup a continuousbuildmachinewithvariousvirtualbuildenvironments www.ngi-central.org

  17. Sample Code • Manycodesamples • Consolesamples • MFC samples • .NET samples • Tests are also samples • UsingBoost.Test • Unit tests, benchmarks, regressiontests www.ngi-central.org

  18. NGI – Guidelines • Header onlylibrary • Source code • Heavy useoftemplates • Concentration on coreissues • usingother Open Source librarieswhereapplicable • Boost, FreeImage, Cairo, Qt www.ngi-central.org

  19. NGI – Concepts • Buffer • storesdata • handlesallocation and deallocation • canuseexternalbuffers • View • levelofindirection • light, just a pointer and a fewpitches • all accessesthroughviews • can handle foreigndatabuffers • viewmanipulations • sub-views (moving_view.exe) • rotatedviews (dimension_swap_view.exe) • reversescanningdirections (reverse_view.exe) • subsampling (subsampling_view.exe) www.ngi-central.org

  20. NGI – FunctionalityOverview (1) • Basic functionsusedeverywhereelse • Interpolation • linear, spline • Geometry • point, line_segment, ray, line, triangle, quadrilateral, rectangle, polygon, circle, ellipse • widgetsfor all geometricelements • Other examples • Base64, ZIP/GZIP Compression/Decompression, Fixed point, Matrix solver, solvingquadratic and cubicequations, etc. www.ngi-central.org

  21. NGI – FunctionalityOverview (2) • STL likefunctions • copy, count, equal, find, ... • Image Processing functions • Point, Filters, Morphology, ... • Image Analysis functions • Blob, Pattern match, OCR/OCV, ... • Display Engine • Images, Palettes, Curves, Widgets, Geometry, ... • Framegrabber/Camerainterface www.ngi-central.org

  22. NGI – STL LikeFunctions • accumulate • copy • count • equal • fill • find • generate • inner_product • max_element • min_element • replace • transform www.ngi-central.org

  23. NGI – Image Processing Functions (1) • Point functions (point_operations.exe, profile.exe) • Filter and morphologicalfunctions (neighborhood_operations.exe) • 1D, 2D, 3D • Separable • Fast box filters – independentofkernelsize • Manypredefinedkernels, usercaneasilyadd • Framing (framing.exe) • Erode, Dilate, Open, Close, Gradient • Gray and binarybehavior www.ngi-central.org

  24. NGI – Image Processing Functions (2) • Binning (binning.exe) • binningmethodselectable/userwritable • Geometric Transformation (resample.exe) • affine / polar • choiceofresampling filter (nearestneighbor, box, triangle, quadratic, cubic, bspline, sinc, kaiser, lanczos) • Autofocus • based on variance, gradient www.ngi-central.org

  25. NGI – Image Processing Functions (3) • Color Processing • Color models (color_transform.exe) • RGB, CMY(K), HLS, HSI, Lab, Lchab, Luv, Lchuv • Color twist (color_twist.exe) • Bayer demosaic • StatisticFunctions • min, max, average, variance, percentiles • CameraCalibration www.ngi-central.org

  26. NGI – Image Analysis Functions (1) • Blob analysis • Thresholding via Otsu‘smethod • 2D, 3D Labelling • Fläche/Volumen • Chain Code (inner, outer), perimeter • Moments • binary, gray • ordinary, central, Hu, Flusser www.ngi-central.org

  27. NGI – Image Analysis Functions (2) • Pattern matching and searching (search.exe) • grayorcolor • usingpyramidforacceleration • OCR/OCV • train a characterset • read/verifytext www.ngi-central.org

  28. NGI - Acceleration • Writtenfor Multi-Core • UsesOpenMP • Most functionsscalenicely, canbeseenwiththebenchmarks • Working on SIMD acceleration • Vector Processing (128 bytechunks) • 16 Pixels at a time • First forpointfunctions • These twomethodsare orthogonal www.ngi-central.org

  29. NGI – Display Engine (1) • Display Engine • Direct2D, GDI Plus, OpenGL, Cairo • Alpha channel support (blit.exe) • Images (file_access.exe) • Palettes (palette.exe, false_color.exe) • Curves (histogram.exe) www.ngi-central.org

  30. NGI – Display Engine (2) • Widgets (scale.exe) • Hierarchicalwidgetcomposition(widget_box.exe) • Callbacksfor smart interaction(horizontal_cursor.exe) www.ngi-central.org

  31. NGI – Framegrabber/Camera • Grabbingintoringbuffer • asynchronous on different thread • live/snapshot • pre-trigger/post-trigger • Gen<i>cam support planned www.ngi-central.org

  32. More Information www.ngi-central.org ngi-central.blogspot.com peter@ngi-central.org www.ngi-central.org

More Related