At DMMD we developed our own signal processing library, which we call DMMD Algorithms, or DMA. One of the first questions we asked ourselves in deciding to develop the new library was:
Why A New Signal Processing Library?
There are many reasons for deciding to develop a new imaging library, including: ability to have full control over the library usage, pride in developing something new, learning experience, and other less technical reasons. However, the number one reason for developing the new DMMD Algorithms Image Processing Library (DMA) is that we did not find any open source software that addressed our particular needs. The open source image processing libraries available today did not address fully some of our needs and we hope that by addressing our needs this library will also address some of your needs. In particular our DMMD Algorithms (DMA) Image Processing Library has the following unique features all contained within one library:
Fast or Safe Memory Access and Easy Boundary Handling: First, DMA
provides fast access to image memory through pointers. In this case the programmer is responsible for making sure that pixel references are not out of bounds. Second, the library also provides methods for accessing image data through safe Set() and Get() functions which safeguard the programmer from accessing out of bounds pixels. These functions are also useful for handling boundary conditions. In fact, it is encouraged that the image processing algorithms be written such that the center of the image is processed using fast memory pointers and the boundary is accessed through the slower and safer Get() Set() methods.
Region of Interest (ROI ) and Multi-Core Parallel Processing: With the
introduction of multi-core CPUs it has become more critical to have the ability to process regions of an image on different cores and at the end to bring together all the results in one image. While this type of parallelization does not work for all image processing algorithms, it is quite impressive to see how many algorithms can take advantage of this methodology of parallelization. Paralleizing an image using regions of interests is not as trivial as dividing an input image into multiple parts and processing each part separately. This is most obvious due to the edge artifacts. Care must be taken in breaking up processing based on ROIs. This also means that eventually the library will be able to handle extremely large data sets, such as streaming data. Furthermore, the parallelization model can be easily extended to cluster computing. Parts of images can be sent to multiple computers and the results will be returned back for assembly into the final image.
Multi-Pixel-Packing and Color Format Support: One issue that is particularly disturbing at times with other libraries is the method by which pixel data is packed. Image data can be packed using pixel packing , plane packing or color palettes. Within a color image data channels can represent different colors. For example one program might expect an RGB ordering, while another might require BGR ordering. Conversion between these formats can be very annoying if the library is written for a specific pixel packing and color format ordering, yet it needs to interface to other programs and libraries that use a different formatting. DMA handles pixel packing, color ordering and other imaging formatting issues seamlessly. DMA processes can take as input one image format and output a different image format as part of its processing without a penalty in performance. DMA does this by abstracting the packing and channel ordering related issues.
Multi-Type and Templates: One ideal feature of the library would have been to be completely template based. While this may seem nice, the requirements that templates had to be exposed in the header file was a big constraint in the design of DMA. DMA uses a pseudo template approach, where through the use of templates the library supports any number of TYPES one desires. Currently, the library supports unsigned char, unsigned short and float and specific processes, such as dmaConvertType are fully templated. New types can be easily added to the mix and specific processes can be easily templated. DMA provides both: the flexibility of templates and the ability of the programmer to encapsulate their own proprietary algorithms in a library for binary distribution. The option is left completely to the end user. For example, DMMD provides the core part of the DMA library as an open source GPL 2.0 code, while the proprietary algorithms are separate and are available only as binary libraries.
Reference Counting: When dealing with large amounts of data, reference counting is a good way of controlling the amount of memory usage. DMA uses shallow copying for reference counting and deep copying for true memory copying. This idea was borrowed from VTK (The Visualization Toolkit for 3D processing). The reference counting idea can be used to generate a dmaImage object without copying any memory. For example, one can use an image memory from a third party library, such as ImageMagick or GraphicsMagick and convert that memory to a dmaImage object without the need to copy any memory. Using reference counting dmaImage will reference the same data as if it was created by dmaImage. By eliminating unnecessary copying, DMA can significantly speed up conversion algorithms between different libraries.
Integrated Data Viewer: The DMA Image Processing Library is closely coupled
with DMMD’s Visere Image Viewer. Visere is a free Windows based image processing program that can be used for opening, viewing, saving, annotating, comparing, batch processing and manipulating 2D images. Visere provides close integration with DMA through the use of plugins.
Small Footprint: DMA is segmented into several projects. To get started with
writing your own image processing algorithms all you need to understand is the core project, that is dmaCoreLib.lib. Using this small library you can easily extend DMA to your own usage. The library dmaBasicLib.lib contains basic image processing algorithms, such as convolution, edge detection, median filtering and the likes. The library dmaProprietary contains DMMD filters that can be licensed for a fee (please contact DMMD for further information). As the library grows we will add new projects and segment the library as we see fit.
Cross Platform Support: DMA has been compiled on several different OSes including: Windows, Mac OS, Linux, Linux with ARM, Android, and iOS.
Test Harness: DMA also provides a test harness that can be used to test the different image processing algorithms. These test harnesses also provide small examples of how to use the image processing library. The tests can also be used as a tutorial on using newly developed algorithms.
In future posts, I will go into more details about the design logic we use to achieve all the features mentioned above.
– Darian Muresan
no comments