BookmarkSubscribeRSS Feed
JohnPonte

Staff

Joined:

Jun 17, 2013

Batch Image Analyzer

Recently I was contacted by a customer asking if there was an easy way to do image analysis in a batch mode. They were familiar with the Image Analyzer but that is an interactive GUI based way of analyzing images. This customer had hundreds of images to process and really just wanted to use JMP to calculate some statistic about each image. To do this in an interactive mode would take a lot of time. So I wrote the Batch Image Analyzer, which turns an image into a JMP data table, just like the Image Analyzer. But it will process a whole directory of images, using JMP to calculate a statistic for the image - in this case calculate the mean of each column.

 

This script does the following:

  • Access a directory - either specified in the script or it will prompt you to navigate to the directory
  • Filter the file list in the directory to be just the image files (based on the specified extenstion). That way it won't attempt to process non-image files in the directory
  • Open each image file and convert the image into a JMP data table, where each pixel is represented as a row of data, just like the Image Analyzer
  • Calculate a statistic, using JMP. In this case the script is calculating the mean of each column (red, green, blue, intensity, hue, lightness, saturation)
  • Produce a data table with the results of the statistical calculation, each row is one image
  • Optionally, it will add a thumbnail of each image into the data table

Processing a batch of images like this can take some time so I added the option of showing a progress bar. The Progress Bar script was added to the File Exchange by @Craige_Hales. To utilize the progress bar with the Batch Image Analyzer, just download the Progress Bar script and comment out the test code at the bottom of that script. Make sure the Progress Bar script is in the same directory as the Batch Image Analyzer script (or modify the path in this script). Then search for "progress" in the Batch Image Analyzer script and uncomment each line. Now you will see a progress bar and know if you have time to get a cup of coffee or go home for the evening.

 

Chances are you will want to modify this script to calculate some other statistic. But this script should give you a nice starting point for batch processing of images. 

 

Enjoy,

John Ponte

 

Article Labels
Article Tags
Contributors