MAPIR Scripts
Search…
Reflectance Calibration
Calibrate images using a photo of our MAPIR Reflectance Calibration Target V2
Please complete the SETUP GUIDE prior to running the below code
We are using an .exe program to copy image metadata (EXIF). For non-Windows users you may need to find another solution to copy image metadata.
  1. 2.
    Locate the project files to a known location path on your computer
  2. 3.
    Create empty working folders inFolder, outFolder, calib (see photo below)
  3. 4.
    Using your cursor right-click on the .bat file in the project files. Select "Edit"
  4. 5.
    This should open the .bat file for editing in your text editing or IDE of choice
Working folder structure
The contents of the .bat follow this structure:
@echo on
This line forces the command window to show when running the script
call "C:\Users\MAPIR\Anaconda3\Scripts\activate.bat"
This line points to the activate.bat file in the Anaconda3 installation folder, so that the scripts use the Python3 version with the previously installed libraries. You chose the installation folder path when you installed Anaconda3, which should not change unless you change where Anaconda3 is installed.
python "calibration.py" "calibration photo path" "input folder path" "output folder path"
This is the main script processing line, which we'll explain in more detail further down the page.
pause >nul
This line keeps the command window open after processing so you can see the processing log.
5. To run the script simply double-click or right-click and select Open on the .bat file.
A command window will pop up and provide feedback during the processing.
The script is done processing when you see the final text "Finished Processing".

Main Script Processing Line Options

The main processing line is where you will make any changes prior to running the script.
Here is the processing line:
python "calibration.py" "calibration photo path" "input folder path" "output folder path"
The blank spaces in the .bat file are very important. Notice the spaces between each argument in the main processing line. If the code format does not match our examples it will not process correctly.
The "calibration photo path" needs to point directly to a photo of our MAPIR Calibration Target V2 package captured shortly before or after the image dataset to be calibrated was captured, and all photos containing the same exposure settings.
Here is an example path if the image was previous converted from RAW+JPG to TIFF:
"%~dp0\calib\calib.tif"
This would be a subfolder named "calib" that contains the calibration photo "calib.tif".
The input and output folder paths need to contain the path to your input image folder and the location you want the processed images to be output to.
We typically create two subfolders named "inFolder" and "outFolder" in the bat working directory. The inFolder is where you put the images you want to process and the outFolder will contain the processed images.
Here is an example of the input and output folder paths:
python "calibration.py" "%~dp0\calib\calib.tif" "%~dp0\inFolder" "%~dp0\outFolder"
Here is an example of an entire .bat ready to be run:
@echo on
call "C:\Users\MAPIR\Anaconda3\Scripts\activate.bat"
python "calibration.py" "%~dp0\calib\calib.tif" "%~dp0\inFolder" "%~dp0\outFolder"
pause >nul
When ran this script will open a command window and begin analyzing the "calib.tif" photo of our calibration target in the subfolder "calib", then it will process the images in subfolder inFolder and save the processed results to subfolder outFolder.
Once you have made all the necessary changes to the .bat file you can save it to begin processing.

Running the Script

To run the script simply double-click or right-click and select Open on the .bat file.
A command window will pop up and provide feedback during the processing.
If you need to stop the processing you can press Ctrl+C and then answer the prompt with Y+Enter
The script is done processing when you see the final text DONE.