Montag, 7. Juli 2014

Creating an image histogram with Excel



An image histogram


About Histograms

In computer vision and photography histograms show the pixel counts of an image grouped by the brightness. Usually this report is represented as a bar chart.


This article shows how to load image data into an Excel spreadsheet. The algorithm may be protected by patents in your country.

Loading image statistics into a spreadsheet

Required components

To load image information into Excel these components are required:
  • An excel spreadsheet with macros (*.xlsm)
  • A .Net Framework Wrapper Library (*.dll) which can be generated with Visual Studio 

Installing a wrapper Library (*.dll)

The wrapper library needs to be COM-visible and has to be registered for COM-interop in the Windows registry. It provides access to the System.Drawing.Bitmap object which provides basic image access routines, in particular the GetPixel(int x, int y) method.

Loading the wrapper library with excel macros

In the VBA window of Excel the wrapper library has to be checked as a reference. Then the wrapper class has to be defined as a variable with the New instruction.

Finally the image data can be inserted in a spreadsheet table.