This series of tutorials will be a walk through on how to process RedEdge data from raw images through conversion to reflectance. We will cover the tools required to do this, and walk through some of the basic image processing and radiometric conversions.
Our tutorials are written using Python3. Python has great library support for image processing through libraries such as OpenCV, SciKit Image, and others. In this tutorial, we'll use python, OpenCV, numpy, and matplotlib, as well as the standalone exiftool and it's python wrapper to open and manipulate RedEdge images to transform raw digital number values into quantitative reflectance. Python 2.7 can also work fine for this tutorial, but later tutorials use some extra libraries that are only supported in Python3 (specifically pysolar), so we recommend that if you're starting with python from scratch to install Python3.
This tutorial has been tested on Windows and Linux. It is likely to work on other platforms, especially unix-based platforms like OSX, but you will have to do the legwork to get the required software installed and working.
The following softare and libraries are required for this tutorial:
Some or all of these commands my need to be run as an administrator by adding sudo
in front depending on your system:
apt-get install python3
apt-get install pip3
apt-get install exiftool
pip install numpy
pip install matplotlib
git clone git://github.com/smarnach/pyexiftool.git
cd pyexiftool
python setup.py install
The installation of OpenCV is a bit more involved, as Python3 bindings may not be available on your system. One approach is to follow the script available here to install from sources.
When installing on Windows we rely on the Anaconda python environment to do most of the heavy lifting for us.
Install Anaconda for your system by downloading the Python 3.6 version
c:\exiftool\
Open an Anaconda console from the start menu as an administrator by clicking Start->Anaconda
, right-click Anaconda Console
, choose Run as Administrator
. Execute the following commands in the anaconda console:
pip install -U numpy
to update numpy to the latest version
conda install -c conda-forge opencv
to install the opencv python bindings and binaries
git clone git://github.com/smarnach/pyexiftool.git
if you have git
, otherwise download the zip file from here and unzip to a temporary directory
cd
to the directory where you checked out pyexiftool
and run python setup.py install
The following python snippet can be run from a jupyter notebook, inside iPython, or by saving to a script and running from the command line. If you're on windows, set the location of exiftool. If this succeeds, your system is ready to go! If not, check the installation documentation for the module import that is having issues.
import cv2 #openCV
import exiftool
import numpy as np
import matplotlib.pyplot as plt
import os
%matplotlib inline
exiftoolPath = None
if os.name == 'nt':
exiftoolPath = 'C:/exiftool/exiftool.exe'
with exiftool.ExifTool(exiftoolPath) as exift:
print('Exiftool works!')
# Use pyplot to load an example image and display with matplotlib
imageName = os.path.join('.','data','0000SET','000','IMG_0000_4.tif')
imageRaw=plt.imread(imageName).T
plt.imshow(imageRaw.T, cmap='gray')
plt.show()
print('Success! Now you are ready for Part 1 of the tutorial.')
Copyright (c) 2017 MicaSense, Inc. For licensing information see the project git repository