The
built in debayer tool of MaximDL (ConvertRGB) uses a derivation of the Nearest
Neighbor Replication algorithm. This is fast, but fairly simplistic in its
results, producing artifacts around the edges of bright stars.
The
algorithm is described below:
Nearest Neighbor Replication
There are several well known alternative algorithms and the plugin below implements the bi-linear interpolation algorithm, also described below:
Bilinear Interpolation
My plugin implementation of the bilinear interpolation debayer algorithm is available for download from the link below.
The new COM interface support allows one to programmatically set the parameters normally set through the dialogue box during interactive execution.
Four methods are exposed:
plugin.SetOffset X, Y – allows one to specify the axis offset values to either 1 or 0. Defaults to zero.
plugin.SetCompensate bool – enables or disables compensation for typical CCD response characteristics. Defaults to false.
plugin.SetAutoBalance bool – enables or disables automatic background colour balance. Defaults to false.
plugin.Debayer doc – Initiates the plugin execution on the specified MaximDL document.
An example script to allow drag-and-drop processing of files is shown below.
Simply paste the text into a file with a .vbs name extension (e.g. “debayer.vbs”) then drag FITS files or a directory containing files from windows explorer onto the icon to have them processed by the plugin.
There is a limit of 255 characters on the list of file/dir names you drag onto the icon.
------------------------------------------------------------------
Dim plugin
Dim doc
Set plugin = CreateObject("Bilinear_debayer.PlugIn")
Set fso = CreateObject("Scripting.FileSystemObject")
Set doc = CreateObject( "MaxIm.Document" )
If wscript.Arguments.Count = 0 Then
MsgBox "No argument filenames were provided"
wscript.Quit
End If
If wscript.Arguments.Count = 1 Then
'Assume only one argument means it is a folder
If fso.FolderExists(wscript.Arguments(0)) Then
Set folder = fso.GetFolder(wscript.Arguments(0))
Set fc = folder.Files
For Each f1 in fc
ProcessIt(f1.path)
Next
Else
'Folder does not exist, so process argument as a file
ProcessIt(wscript.Arguments(0))
End If
Else
'Multiple arguments = files
For I = 1 To wscript.Arguments.Count
ProcessIt(wscript.Arguments( I - 1 ))
Next
End If
Function ProcessIt(file)
doc.OpenFile file
plugin.SetOffset 0,1
plugin.SetCompensate true
plugin.SetAutoBalance true
plugin.Debayer doc
doc.SaveFile file, 3, false, 1, 1
End Function
------------------------------------------------------------------
Release notes:
V1.0 - Initial release - includes optional CCD spectral response compensation.
V1.1 – Provides COM interface for scripted execution support.
V1.2 – Adds optional automatic background colour balance processing.
If you use this plugin, please give me feedback via the MaximDL yahoo group, or by email to winfij_AT_gmail_DOT_com
Regards,
John
(Algorithm descriptions courtesy of Ting Chen)