module snowpyt.nirpy
Collection of NIR processing tools S. Filhol, March 2022
Inpired by the paper by Matzl and Schneebeli 2016 for more info
A calibration profile was derived from the camera with Micmac. This calibration profile is for correcting vigneting. correct image for vignetting (calib profile is of the size of Raw images. Crop from center to use with jpegs detrend if needed the luminosity, as it can vary linearly from top to bottom of the snowpit sample targets for absolute reflectance calibration (white= 99%, and grey=50%). Fit a linear model Convert reflectance image to SSA with the conversion equation 𝑆𝑆𝐴=𝐴𝑒𝑟/𝑡
Finally, use the ruler (or other object of know size) in image to scale image dimension to metric system.
TODO:
write function to extract SSA profile to import in niviz.org
Raw images are in 12 bit. Find a way to convert to BW from original while maintaining the 12bit resolution. Rawpy might be useful. Then make sure the processing pipeline can accept 12bit data (i.e. all skimage functions)
wrap micmac function to extract profile ‘mm3d vodka’. At least provide the method on how to do it.
function kernel_square
kernel_square(nPix)
Function to defin a square kernel of equal value for performing averaging
Args:
nPix
(int): size of the kernel in pixel
Returns:
array
: kernel matrix
function smooth
smooth(mat, kernel)
Function that produce a smoothed version of the 2D array
Args:
mat
: 2D Array to smoothkernel
: kernel array (output) from the function kernel_square()
Returns:
2D array
: smoothed array
function micmac_radiometric
micmac_radiometric()
List of commands to run for deriving a radiometric calibratino profile for the camera
class nir
Class to process NIR snowpit photograph.
method __init__
__init__(
fname_nir,
fname_calib,
highpass=True,
kernel_size=2000,
rotate_calib=False
)
Class initialization
Args:
fname_nir
(str): path to NIR imagefname_calib
(str): path to radiometric calibration imagehighpass
(bool): perform high pass filtering to remove luminosity gradient across the pitkernel_size
(int): size of the kernel for the highpass filter
method apply_calib
apply_calib(crop_calib=False)
Function to apply calibration profile to the NIR image.
Args:
crop_calib
(bool): if calibration and image are of slightly different size, crop calib and align the two with center.
method convert_all
convert_all()
Function to convert pixel values to physical values using the targets
method convert_to_SSA
convert_to_SSA()
Function to convert reflectance to SSA
method convert_to_doptic
convert_to_doptic()
Function to convert SSA to optical diameter
method convert_to_reflectance
convert_to_reflectance()
Function to convert image to reflectance using at minimum 2 sets of reflectance targets previously picked
method extract_profile
extract_profile(
imgs=['SSA', 'reflectance', 'd_optical'],
param={'method': <module 'scipy' from '/home/simonfi/miniconda3/envs/dataAna/lib/python3.8/site-packages/scipy/__init__.py'>, 'n_samples': 1000}
)
Function to extract profile of values for a list of images
Args:
imgs
(list): images from which to sample profile param (dict):method
(str): method to sample the profile. Avail: numpy, scipy, and skimage.n_sample
(int, numpy and scipy method): number of samples along profilelinewidth
(int, skimage method): width of the profilereduce_func
(func, skimage method): function to agglomerate the pixels perpendicular to the linespline_order
(int, 0-5, skimage method): order of the spline applied to the sampled profile
examples: {’method’: scipy, ‘n_samples’:1000}, {’method’: numpy, ‘n_samples’:1000}, {’method’: skimage, ‘linewidth’:5, ‘reduce_func’:np.median, ‘spline_order’:1}
method load_calib
load_calib()
Function to load radiometrci calibration file
method load_nir
load_nir()
Function to load jpeg NIR images, and convert them to BW
method pick_targets
pick_targets(reflectances=[99, 50])
Function to pick reflectance targets
Args:
reflectances
(list of int): List of reflectance targets to pick
method scale_spatially
scale_spatially()
Function to bring real spatial coordinate
Method: 1. click two points 2. provide corresponding length 3. option to provide geometrical correction
This file was automatically generated via lazydocs.