Multipass Image Processing for Barcode Recognition: 25 Projects in 25 Days

Before Recognition
Successful Recognition
Successful Recognition
Recognized First Try
Recognized First Try

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Faris.

What it Does

This project will perform various image cleanup functions until a barcode is recognized using LEADTOOLS Version 19. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Features Used

Development Progress Journal

My name is Faris and I’m going to create a program which will try recognizing a barcode. If it fails, it will perform different image processing operations on the loaded image then try again after each operation. The total number of tries is 4. The image processing operations are stacked on the same image. The image processing is done to clean-up the barcode for the barcode engine to recognize since unclear images tend to not be recognized from the first try.

In this project, I will use LEADTOOLS Document Imaging SDK and program using .NET C# programming language. LEADTOOLS Document Imaging SDK provides me with the ability to read 1D and 2D barcodes and also the ability to perform image processing operations. The reading operation will go through 4 steps: read the barcode as is without any modification, increase the image’s size and Dots per Inch (DPI) if its resolution is below 300 DPI, perform auto-binarize operation on the image and change its bits per pixel (BPP) to 1, and finally perform the Minimum image processing algorithm on the image.

If all 4 steps fail, then no barcode was recognized.

Note that this is not considered a complete solution for all cases, but rather a template that can be customized based on the nature of images typically present in a work environment. If these 4 steps are used with the wrong images, they may actually worsen the image rather than improve it.

First, I will start with a new WinForms application in Visual Studio 2010. In the form, I will add a menu, a Rich Textbox to show the operation currently being performed by the program, and our ImageViewer component to view the loaded image. I will also add the needed SDK references for loading and processing the image, and for barcode functionality.

I have now added the needed code to load the image, which only took me a few minutes because our SDK greatly simplifies loading almost any type of image on Earth.

To read a barcode, I will need to use LEADTOOLS BarcodeEngine class.
Documentation: BarcodeEngine class

The barcode can be easily read using a single line of code with ReadBarcode method.
Documentation: ReadBarcode

The program will look in all symbologies and in both horizontal and vertical directions. The directions should be set using BarcodeReadOptions class. As I haven’t used that class often, I’m using the example in our online help documentation to set the default barcode options except for the barcode direction, which I will change to use both horizontal and vertical.
Documentation: BarcodeReadOptions

After about one hour, basic barcode reading for all types is ready. Next, I will add the different processing features.

In my code, I’m using a switch statement to go through the current iteration. Reading is done after every operation, which means placing ReadBarcode method outside the scope of switch case. The first case (case 1) is not taken into consideration as nothing will be changed on the current loaded image.

For the other cases, I used the corresponding Command class with the image processing operation:

  • ResizeCommand class to resize the image. (Note: This does NOT affect the DPI, so I change the DPI using the XResolution and YResolution properties of the RasterImage object)
  • AutoBinarizeCommand class to convert the image to B/W then ColorResolutionCommand class to change the image’s BPP.
  • MinimumCommand class to dilate dark objects.
  • The commands mentioned above helped me apply image processing operations with only a few lines of code. Also, LEADTOOLS’ online help documentation provided me with a small code snippet to use as a reference or to take it as is. For example, here’s the help topic for the MinimumCommand class:
    Documentation: MinimumCommand

    This part is now done and it took about one hour of work.

    Next I will be finishing the interface and finalizing exception handling and user interaction.

    This took about an hour and a half and I’m now satisfied with how the program looks and interacts.

    Lastly comes testing, for which I will use different images with barcodes.

    This part took more time than the previous steps combined. The LEADTOOLS barcode engine itself is powerful, so many of the images I tested with did not need my processing functions. I also tested on multiple images which were of poor quality, and the program managed to clean them up using the image processing operations I implemented. To completely test the application, I had to take an image with a barcode in it, then lower its quality using different processing techniques so as to go through all implemented image processing operations. All testing took about 4 hours.

    The total amount of time taken to develop, debug and test the application from scratch was 7 and a half hours. Without LEADTOOLS SDK helping me finish all functionality coding in only 2 hours, this application would not have been possible to finish in a single day’s work.

Download the Project

The source code for this sample project can be downloaded from here.

Posted in Barcode | Tagged , , , , , , , , , | Leave a comment

DICOM Encapsulated PDF: 25 Projects in 25 Days

Dicom Encapsulated Pdf Screenshot
Dicom Encapsulated Pdf Screenshot

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Joe.

What it Does

This project embeds PDF documents inside DICOM Data Sets using LEADTOOLS Version 19.

Features Used

Development Progress Journal

My name is Joe and I am going to create a project that embeds a PDF in a DICOM File as an encapsulated document using the Encapsulated Document tag (0042:0011).

I am using LEADTOOLS Medical Imaging 19.0. I’m developing this application using Visual Studio 2013 using C# .NET 4.5.

After starting up Visual Studio, I selected a Windows Forms Application as this is the simplest to design for this demonstration. I added the Leadtools, Leadtools.Codecs, Leadtools.Dicom, and Leadtools.WinForms DLLs as references to my project.

Now that I have all of the references that I’ll need, I’m going to work on the designer. I’ve added two buttons and a RasterImageViewer to the form.

I’ve linked up the button’s click methods to my main form. The first button, “Create,” will be written to create a DicomDataSet, load a PDF file, insert that PDF into the DicomDataSet and then save out the DicomDataSet. The second button, “Load,” will be written to load the DicomDataSet with the encapsulated PDF that was created and saved out by the “Create” button.

I just wrote the code for the “Create” button. I created a helper method to set all of the properties of the DICOM File when encapsulating a document. The main method used to encapsulate the PDF was DicomDataSet.SetEncapsulatedDocument. Easy enough.
Documentation: SetEncapsulatedDocument function

I just wrote the code for the “Load” button. I again created a helper method to do the extraction of the PDF. This helper method does three things:

  1. Extracts the PDF from the DicomDataSet
  2. Prints out all of the properties of the DicomDataSet
  3. Rasterizes and Displays the PDF in the RasterImageViewer

Now when I run the demo, clicking the “Create” button generates a DicomDataSet, embeds a PDF as an encapsulated document, and then saves out the DICOM File. The “Load” button now loads the generated DICOM File, displays the properties, extracts the PDF, and then rasterizes and displays it in the viewer.

This project took me 3 hours to set up. The main time consumer in creating this application was figuring out which properties to set in the DicomDataSet when creating it. Other than that, all of the methods that needed to be called on the DicomDataSet class were fairly straight forward. Without the high-level LEADTOOLS SDK, it may have taken me days to accomplish this due to the complexity of the DICOM format.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Posted in Medical Imaging | Tagged , , , , , , , , , | 2 Comments

Video to GIF: 25 Projects in 25 Days

Video to GIF Screenshot
Video to GIF Screenshot
Video to GIF Screenshot In Progress
Video to GIF Screenshot In Progress

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Hadi.

What it Does

This C# WinForms app will convert a video to animated GIF using LEADTOOLS Multimedia Version 19.

Features Used

Development Progress Journal

Hello, my name is Hadi and I’m going to write a sample application that will convert any media file to a GIF with various options, such as start and end time and frame rate.

When starting the application, I had 2 different paths I could take. I could have used our DirectShow Video Callback or our Still Image Writer Filter.

The LEADTOOLS Still Image Writer Filter would be a simpler implementation, so I’ll go with it.

I am going to use our ConvertCtrl to achieve this, since it has built in support for using the Still Image Writer. Documentation: Convert Control

Using the LEADTOOLS Multimedia SDK will save me a lot of time because DirectShow is very low level and would require many hours to learn and code.

I’ve finished working on the user interface for the project. I’ve kept it all on one form for simplicity. This took around an hour.

I’ve finished working on getting the video file to a GIF. This was actually very simple because the LEADTOOLS ConvertCtrl and the Still Image Writer Filter are handling most of the work. This took only half an hour. Documentation: Still Image Writer

Now I’m implementing the various properties the user can set: Start/End time and Frame Rate.

I needed to use the LEADTOOLS MediaInfo class which has again saved me a ton of time by easily accessing the metadata of the video file. Documentation: MediaInfo class

I’ve got it mostly working. I’m having some issues remembering how to use the Frame Rate Control Filter. I need to review our documentation. Documentation: Frame Rate Control Filter

Success! I got it working with the Frame Rate Control Filter and the Start and End time. It has taken me 4 hours total so far. I’m doing some testing now.

Added some error checking to make sure invalid parameters can’t be passed and commented the code for easy reading.

My app is ready to deploy. It took me a total of 5 hours, including R&D. Without LEADTOOLS this would have taken me many weeks, if not months to complete.

Next time I would use our Video Resize Filter since that will give the users more options to set when converting the media to GIF and would help reduce the overall file size. Documentation: Video Resize Filter

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.

Posted in Multimedia Imaging | Tagged , , , , , , , , , , , , | Leave a comment

LEADTOOLS Multimedia Updates: RTSP, Media Streaming Server & H.264

Today we released several updates to LEADTOOLS Multimedia Version 19. These include new features and enhancements to RTSP, Media Streaming Server, and H.264

  • RTSP Source filter now has callbacks for indicating the remote server has stopped sending data and when the connection was lost
  • Enhanced H.264 encoding for SSF, Adobe HDS and MPEG-DASH within the Media Streaming Server
  • Improved load time for MP4 files with H.264 video compression

All of these new features are freely available to those evaluating and who have already purchased LEADTOOLS Version 19. All you need to do is download the latest setup from our website!

Posted in Multimedia Imaging | Leave a comment

iOS Stacked Image Processing: 25 Projects in 25 Days

Stacked Image Processing Screenshot
Stacked Image Processing Screenshot

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Joe.

What it Does

This Objective-C project will process images using LEADTOOLS Version 18.

Features Used

Development Progress Journal

My name is Joe and I am going to create a project that will perform various Image Processing commands on an image, one stacked on top of another. Currently we ship a demo titled “IPDemo” that performs Image Processing commands, however, the commands are always processed on the original image and therefore they never stack. My project will stack these commands.

I am using LEADTOOLS Imaging Pro version 18 (iOS). I’m developing this application using Apple’s native programming environment, Xcode.

First I needed to select which language to use. Since our frameworks have been developed in Objective-C, I’m going to use that language to develop with.

After starting up Xcode, I selected a Single View Application since we only need one view. After looking at the IPDemo that ships with the SDK, I found a helper class (DemoCommandItem) that is going to be useful, so I imported into the project. I added the Leadtools, Leadtools.Kernel, Leadtools.Controls, Leadtools.Converters, and all of the Leadtools.ImageProcessing.* frameworks.

After I imported all of the frameworks, I added them to the precompiled header file for the project. (Note that I’m using the LEADTOOLS templates provided here so the precompiled header file and the project settings have been configured for me).

Now that I have all of the LEADTOOLS frameworks added, I compiled quickly to make the LEADTOOLS API publically available in all files. I then proceeded to configure my Storyboard. In the main view I added an instance of the LTImageViewer class and a UICollectionView class (for the thumbnails).
Documentation: LTImageViewer control

Now in my ViewController class, I wrote the code for setting the bar button items (for loading the commands), the array to hold all of the commands, another array to act as a stack for allowing us to undo the commands, and then I set up the delegate and dataSource methods for the UICollectionView that I have in the main view.

Since LEADTOOLS provides all of the Image Processing commands that I’m using, that’s all that I had to do. When I run it, now I can scroll through all of the thumbnails to select the command that I want to use. Once I run the command, all of the thumbnails update to show me what running the next command on the current image will now look like. Super easy.

This project, all in all, took me 5 hours to set up. The main issue that I had was in setting up the custom UICollectionView class (not LEADTOOLS related). The LEADTOOLS portion of this project took no more than an hour to two hours to fully configure.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the \Leadtools 18\Examples\Xcode\iOS\ directory.

Posted in Image Processing | Tagged , , , , , , , | Leave a comment