Histogrammer for MaxIm DL 3


Histogrammer is a freeware MaxIm DL plug-in that demonstrates how to write a plug-in that modifies the image histogram.

Histogrammer requires MaxIm DL version 3.07 or later.

Description | Installation | Quick Start | Reference | Scripting | Properties | Methods

DESCRIPTION

Histogrammer is a demonstration plug-in that shows how a plug-in can be used to alter the histogram of an image. The demo version applies a shifted and modified Gaussian curve to the image histogram. Dim values in the image are emphasized, and bright data is sacrificed.

You may also want to download the source code. This is a Visual Basic 6 program, but it could be converted to Scripting with a little effort.

The shift in the Gaussian curve is to the left, toward the origin. This results in the greatest changes being made to the data that is closest in brightness to the background level.

The modification is to put downward wings on the areas outside the immediate area of the Gaussian peak. This smoothes the impact of the histogram change outside the are of main interest. A side effect of this modification is that data values outside the range of the Gaussian boost are actually reduced in value, so I added an Aggressiveness setting that allows you to control the curve. You'll need to find the Aggressiveness sweet spot for any given image.

TOP

INSTALLATION

Unzip the Histogrammer plug-in and copy it to the MaxIm DL install folder:

C:\Program Files\Diffraction Limited\MaxIm DL 3\

If necessary, change this to the location where you installed MaxIm DL 3.07 or later.

Start MaxIm DL, and click the Plug-in | Add/Remove Plug-in... menu item. Click the Browse button and locate the plug-in (navigate to the MaxIm DL program folder, and highlight histogrammer.dll), and click Open. This takes you back to the Add/Remove Plug-in dialog; click Close. 

Note: MaxIm DL will register the DLL with Windows for you. If you download an upgrade, the installation process is similar. Unzip to the MaxIm DL folder, remove the plug-in in MaxIm, then add it back in.  Removing then adding properly registers the new version with Windows.

TOP

QUICK START

If the histogram stays fairly level, or if you see portions of the image negative, try a larger aggressiveness setting (e.g., 100, then 120, etc.) Aggressiveness settings of 25 to 500 work for various images.

TOP

REFERENCE

Invert final image (negative) - When checked, the end result is an inverted (negative) image. This is ideal for showing the faintest detail in the image most clearly.

Save histogram to disk - When checked, a one-tenth scale histogram is saved to your hard disk (default file is C:\testfile.csv). You cannot change the filename, although you can specify a different filename if you use the scripting interface for the plug-in. The format of the file is a comma-delimited set of points that describe the histogram:

10,50
20,0
30,2
40,0
50,2
60,0
70,4
80,16
90,35
100,31
110,25
120,24
...

The second column is always an average of the preceding 10 values. This is thus a one-tenth scale histogram, and it is sufficient for most purposes - Excel can't even graph a 65,535-value histogram! You can load the output file into Excel and graph the histogram. Select the second column, and Insert a Chart of type Line.

Aggressiveness - Lower numbers are less aggressive. Start with values in the range of 55 to 80, and increase if the effect isn't strong enough.

The equations used for the histogram adjustment are:

k = (1 + ( Aggressiveness / 100000000))
y = ((x + 1000) * k ^ (-(x - 100) ^ 2)) - (x * 0.0007) ^ 2

You can download the source for this plug-in.

TOP

SCRIPTING

You can create an instance of the Histogrammer plug-in for use in scripting.

To create an object in Visual Basic:

Set hist = CreateObject("Histogrammer.Plugin")

The following sample code sets the settings and calls the call:

Private Sub cmdTest_Click()
Set myTempDoc = CreateObject("MaxIm.Document")
myTempDoc.OpenFile "myImage.fit"
chgHist myTempDoc
End Sub

Public Sub chgHist(myDoc As Object)
Set hist = CreateObject("Histogrammer.Plugin")
' Set up options.
hist.Invert = 0
hist.SaveHistogram = 1
hist.Aggressiveness = 90
hist.SaveHistogramFilename = "d:\histfiles\myfile1.csv"

' Perform change.
hist.alterHistogram myDoc
' Clean up object. 
Set hist = Nothing
End Sub

TOP

Properties:

hist.Invert as Integer
------------------------------------------------------------------
Only two values are legal:

1 = Invert the image
0 = Do not invert the image

hist.SaveHistogram as Integer
------------------------------------------------------------------
Only two values are legal:

1 = Save the histogram to a file
0 = Do not save to a file

hist.SaveHistrogramFilename as String
------------------------------------------------------------------
Sets the filename of the output file. If not specified, 
the default of C:\testfile.csv is used.

hist.Aggressiveness as Integer
------------------------------------------------------------------
Sets the aggressiveness value for the operation. 
Legal values are greater than 10 and less than 1000.

TOP

Methods:

hist.alterHistogram(inDoc As Object)
------------------------------------------------------------------
Takes a Maxim.Document object as its argument. 
Specifies the document that is to be changed. 
Returns nothing. Note that you must declare the 
object as object, not as a MaxIm DL Document!

TOP

Author: Ron Wodaski
support@newastro.com