---
description: >-
  Use the following information to convert the Kernel2 RAW images into TIFF
  images.
---

# Convert RAW(.mapir) to TIFF

{% hint style="info" %}
Please complete the [SETUP GUIDE](../setup-do-this-first) prior to running the below code
{% endhint %}

1. Download project files HERE
2. Unzip and extract the contents of the project files to a known location path on your computer
3. Using your cursor right-click on the .bat file in the project files. Select "Edit"
4. This should open the .bat file for editing in Notepad or similar program (or you can open the .bat in your text editing or IDE of choice)

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 "ConvertKernelToTiff.py" -parameters "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.

{% hint style="info" %}
If you need to stop the processing you can press Ctrl+C and then answer the prompt with Y+Enter
{% endhint %}

The script is done processing when you see the final text "DONE".

## Main Script Processing Line Options

The main processing line is where you will make any changes prior to running the script.&#x20;

Here is the processing line:

```
python "ConvertKernelToTiff.py" -parameters "input folder path" "output folder path"
```

{% hint style="info" %}
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.
{% endhint %}

The parameters are processing options you can choose to use as follows:

| Parameter Name      | Parameter Command | Explanation                                          |
| ------------------- | ----------------- | ---------------------------------------------------- |
| White Balance       | -wb               | Applies a white balance to the images (if supported) |
| Vignette Correction | -vig              | Applies a vignette correction (if supported)         |

To apply a parameter it would look like:

```
python "ConvertKernelToTiff.py" -wb "input folder path" "output folder path"
```

To apply multiple parameters it would look like:

```
python "ConvertKernelToTiff.py" -wb -vig "input folder path" "output folder path"
```

If an image in your input folder does not support a parameter it will tell you in the processing log window.



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.

Here is an example of the input and output folder paths:

```
python "ConvertKernelToTiff.py" "C:\Users\MAPIR\Desktop\inFolder" "C:\Users\MAPIR\Desktop\outFolder"
```

And with multiple parameters applied:

```
python "ConvertKernelToTiff.py" -wb -vig "C:\Users\MAPIR\Desktop\inFolder" "C:\Users\MAPIR\Desktop\outFolder"
```

The images in the output folder will be saved to a subfolder named Processed\_N, where N starts at 1 and counts up depending on if there are already other Processed folders located in the output folder or not. This is ideal so that you can output to the same location every time and it will not overwrite your previously processed images.

Here is an example of an entire .bat ready to be run:

```
@echo on
call "C:\Users\MAPIR\Anaconda3\Scripts\activate.bat"
python "ConvertKernelToTiff.py" -wb "C:\Users\MAPIR\Desktop\inFolder" "C:\Users\MAPIR\Desktop\outFolder"
pause >nul
```

_When ran this script will open a command window and begin processing the images in folder C:\Users\MAPIR\Desktop\inFolder and save the processed results to folder C:\Users\MAPIR\Desktop\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.

{% hint style="info" %}
If you need to stop the processing you can press Ctrl+C and then answer the prompt with Y+Enter
{% endhint %}

The script is done processing when you see the final text "DONE".
