Enfuse Simple Fusion – the batch file – updated 14/7/2015

I created the ESF batch file and wrote this article because I was so frustrated on what I found on command line examples for Enfuse on the internet.
Most of them were not complete and/or didn’t’ work at all, many had errors.
At a certain point I contacted the Enfuse support group on Google, to help me with path problems etc.
Members of the support group told me that the script I used contained codes that didn’t exist for Enfuse and contained errors – I got my script from the internet.
The following article, batch file and script examples for use with Enfuse, is tested and works !
I can guarantee that !

This script can be downloaded here : My Downloads

Enfuse Simple Fusion is a batch file for use with Enfuse.
In contrary than the ESF Reactor, this batch file needs 2 components to work :
the enfuse.exe file and the vcomp110.dll.
The ESF Reactor is a compiled version of this batch file, and contains all the needed components. But, because its compiled, you can not change its programming, and that part is just what it makes interesting.
From the point you understand how the batch file works, you can edit it, or create your own version.

This batch file is build on the same principle as my previous batch file scripts.
Its easy, and you can use the framework to control just almost any command line program.

Part 1 ) the script for the menu :

Script-ESF-menu

 

Text version of the script :

You need to line out the “º” for the menu box – see the difference between code below and screenprint above – this can be done in any simple editor like Windows Notepad, better is Notepad++ . Copy the code/text below and paste it in the editor.
:fusion_menu
TITLE Enfuse Simple Fusion v1.0
color 2E
@echo off
CLS
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO º º
ECHO º Enfuse Simple Fusion º
ECHO º ————————————— º
ECHO º º
ECHO º 1. Set Fusion Folder – ex. c:\pictures\fuse\ º
ECHO º º
ECHO º 2. Basic Fusion º
ECHO º º
ECHO º 3. Contrast Edge ( Set Parameter ) º
ECHO º º
ECHO º 4. Contrast Window ( Set Parameter ) º
ECHO º º
ECHO º 5. Gray Projector ( Set Parameter ) º
ECHO º º
ECHO º 6. Open Enfuse Simple Fusion Manual º
ECHO º º
ECHO º 7. Open and Save Enfuse Help º
ECHO º º
ECHO º Q. Quit º
ECHO º º
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

set /p Choice=Enter: 1,2,3,.. or Q to Quit –
echo.
if [%Choice%]==[1] goto fusion_folder
if [%Choice%]==[2] goto basic_fusion
if [%Choice%]==[3] goto contrast_edge
if [%Choice%]==[4] goto contrast_window
if [%Choice%]==[5] goto gray_projector
if [%Choice%]==[6] goto simple_manual
if [%Choice%]==[7] goto enfuse_help
if [%Choice%]==[q] goto end
if [%Choice%]==[Q] goto end
For %%a in (1,2,3,..9,q,Q) do if not [%Choice%]==[%%a] goto end

Part 2) the command line that points to the images

Script-ESF-command-line-part1

The first thing we have to do is tell Enfuse where to find the images to work on.
That’s the input folder, but also where to put its output image.
To make this easy, I used the same path for output as input, so all images stay together in one folder.
Also important is to put all the images to be fused in one folder, the reason for that is because I dont want to input every single image name, but just a wildcard for it – in this case “TIFF” – because of that, it takes all TIFFs from the given folder.
The Windows command line to set the folder is : set /p input=Set Fusion Folder
The first part is mandatory ( set /p ) – the word “input” can be anything, but will be used afterwards in the Enfuse command line to know where to put the images path – what will be referred as %input%.
The last part “=Set Fusion Folder” is only a text for you to know what to do.
This results in :

:fusion_folder
color 1F
echo.
set /p input=Set Fusion Folder :
echo.
goto fusion_menu

Part 3) the code that runs Enfuse

:basic_fusion
color 1F
echo Run basic fusion on folder
echo.
enfuse –exposure-weight=0 –saturation-weight=0 –contrast-weight=1 –hard-mask –output=%input%base_fused.tif %input%*.tif
pause
goto fusion_menu

Every part of a program that is menu driven like my batch file, needs to have an identifier. This identifier ensures that the right part of the batch file is started.
In my batch file, the menu has numbers for each choice toe make.
If you press a certain number, like 2, the number is then changed to a more understandable name – like in this case basic_fusion :
if [%Choice%]==[2] goto basic_fusion
The “goto” part says to go to that part of the batch file.

Every new code part starts with a colon (:) and the a name from the choices list.
In the example above this is :
:basic_fusion

I use a new color code then above for the menu, so you have a visual confirmation the batch file is running.
color 1F

That is folowed by a sentence that explains the given command.
echo Run basic fusion on folder

Then the final Enfuse command line, with the images path and the path to place the output at the end of the code line. In my case I used for input and output the same path. ( %input% )
Also, the script exepts only TIFF images ( but that can be changed )
enfuse –exposure-weight=0 –saturation-weight=0 –contrast-weight=1 –hard-mask –output=%input%base_fused.tif %input%*.tif

Finaly, a “pause” to halt the program until you press any key, and a return code to reset the batch file to its original menu.
pause
goto fusion_menu

Part 4 ) Enfuse command line code with extra parameter input

Script-ESF-command-line-part2

 

The basic fusion code was simple, you needed to press the number for it and it just runs.
Now we are going to use an Enfuse command that needs a certain value to be set.
This value or parameter can be set with an extra command line, that resembles the code for setting path.
Lets take a look at the code for “contrast_edge” :

:contrast_edge
color 1F
echo.
set /p ces=enter a value between 0.1 and 0.5
echo.
echo Run Contrast Edge fusion on folder
echo.
enfuse –exposure-weight=0 –saturation-weight=0 –contrast-weight=1 –hard-mask –contrast-edge-scale=%ces% –output=%input%edge_fused.tif %input%*.tif
pause
goto fusion_menu

The extra command is : set /p ces=enter a value between 0.1 and 0.5
just as in setting the path, the “set /p” controls wat to be set – the “ces” is the identifier afterwards used in the Enfuse command line :
–contrast-edge-scale=%ces%
( ces is abbreviation for contrast edge scale )
When the command line runs and hits the “set /p” line, it asks you to input a value :
set /p ces=enter a value between 0.1 and 0.5
When done, the program continues to the next line.

The same is used for the “gray_projector” command, where a text value is to be entered instead of a number :
:gray_projector
color 1F
echo.
set /p gpv=enter a parameter
echo.
echo Run Gray Projector Fusion on folder
echo.
enfuse –exposure-weight=0 –saturation-weight=0 –contrast-weight=1 –hard-mask –gray-projector=%gpv% –output=%input%gray_proj_fused.tif %input%*.tif
pause
goto fusion_menu

Here we use the following extra code:
set /p gpv=enter a parameter
–gray-projector=%gpv%
( gpv stands for gray projector value – simple as that – but you can virtually use anything )
These “gpv” values can be found in the enfuse help file.

Part 5 ) End of the batch file script

Script-ESF-end

 

The batch file ends with the following code:
:simple_manual
color 1F
ECHO ENFUSE SIMPLE FUSION MANUAL
ECHO —————————
ECHO option 1)
ECHO Input the folder path of the images to Enfuse,
ECHO the folder path needs a slash at the end (\)
ECHO example : c:\pictures\fuse
ECHO A folder path with to many caracters can cause problems.
ECHO option 2)
ECHO Basic Fusion, no further parameters need to be entered.
ECHO Option 3) to Option 5)
ECHO Expert Fusion modes, need extra parameter to be entered,
ECHO these option parameters are to be found in the Enfuse help file
ECHO Option 6) and Option 7)
ECHO First : this simple instruction manual
ECHO Second : use an command line parameters for Enfuse
ECHO Q : exit the program
ECHO.
pause
goto fusion_menu

:enfuse_help
color 1F
echo Save and Open Enfuse Help
echo.
enfuse.exe –help >enfuse_help.txt
enfuse_help.txt
pause
goto fusion_menu
:end
exit

First a simple ESF manual, followed with the Enfuse help, which runs with :
enfuse.exe –help >enfuse_help.txt
enfuse_help.txt
the “enfuse.exe –help” runs the help, and the “enfuse_help.txt” prints its contents in a text file named “enfuse_help.txt
The “enfuse_help.txt” then runs notepad to open that file.

Finaly :
:end
exit
closes the batch file.

How it works video’s :

Part 6 ) Extra script examples

The set /p is a very powerful command,
you could virtually use it to input a whole lot of codes at once
If you would use this command :
set /p anything=enter anything you want
and enter the identifier “anything” behind the enfuse command, you can type any command you like to run enfuse.
enfuse %anything% –output=%input%base_fused.tif %input%*.tif

It’s also possible to use the “set /p” switch more than once.
you only need to use different identifiers.
For example you can write a script like this :

:interactive_fusion
color 1F
set /p filetype=enter the filetype you want to fuse ( tiff – jpg )
set /p command=enter one or more command lines
set /p input=set fusion folder
set /p output=set output folder
echo Run Interactive fusion on folder
echo.
enfuse %command% –output=%output%interactive_fused.%filetype% %input%*.%filetype%
pause
goto fusion_menu

In this example, you can interactively choose your input file type ( tiff-jpg ), enter your choise of commands and choose different input and output paths.

Another use of the “set /p” switch is to use “predefined settings”.
You will probably use the same commands over and over again, instead of typing them over and over again, you could use a text file with these commands, that you saved before.
for example :

:my_fusion
color 1F
set /p my_setting=<my_setting.txt
echo.
enfuse %my_setting% –output=%input%base_fused.tif %input%*.tif
pause
goto fusion_menu

If you save a text file in the same folder as this batch file, with the name my_setting.txt,
and you save it containing the text “–exposure-weight=0 –saturation-weight=0 –contrast-weight=1 –hard-mask
The batch file will use the commands in this text file to run Enfuse.

Of course you could use different identifiers and text files, to use different settings.
Like :
set /p my_setting=enter the name of your setting
and text file my_setting1.txt
and
and text file my_setting2.txt

Now you just need to type my_setting1.txt or my_setting2.txt, and the batch file uses the settings in the text file to run Enfuse.

 

Leave a Reply

Your email address will not be published. Required fields are marked *