<jupyter_start><jupyter_text>Identify calibration targetsAttempt to automatically locate the calibration target in each scene. If this fails for any images then the target can be located manually. Note that the automated method only works for scenes containing a single target!Calibration spectra ( measured radiance vs known reflectance ) are then extracted from the targets and stored in the image .hdr files.<jupyter_code>import os
import glob
import numpy as np
from tqdm.auto import tqdm

import hylite
import hylite.io as io
from hylite.correct import Panel<jupyter_output><empty_output><jupyter_text>Define data directories<jupyter_code># input directory containing images to locate (these should all be captured from about the same location)
path = '/Users/thiele67/Documents/Data/SPAIN/2020_Sierra_Bullones/20200309_sun/elc'
image_paths = glob.glob( os.path.join(path,"*.hdr"), recursive=True )
print("Found %d images:" % len(image_paths))
for p in image_paths:
    print(p)<jupyter_output>Found 4 images:
/Users/thiele67/Documents/Data/SPAIN/2020_Sierra_Bullones/20200309_sun/elc/0066ELC.hdr
/Users/thiele67/Documents/Data/SPAIN/2020_Sierra_Bullones/20200309_sun/elc/0068ELC.hdr
/Users/thiele67/Documents/Data/SPAIN/2020_Sierra_Bullones/20200309_sun/elc/0067ELC.hdr
/Users/thiele67/Documents/Data/SPAIN/2020_Sierra_Bullones/20200309_sun/elc/0065ELC.hdr<jupyter_text>Define calibration panel material<jupyter_code>from hylite.reference.spectra import R90, R50, PVC_Red, PVC_White, PVC_Grey # load calibration material spectra
M = R90 # define calibration panel material<jupyter_output><empty_output><jupyter_text>Attempt to automatically identify targets<jupyter_code>for i,p in enumerate(tqdm(image_paths)):
    
    image = io.loadWithGDAL( p ) #load image
    image.set_as_nan(0) # set nans 
    
    target = Panel(M,image,method='auto', bands=hylite.RGB) # look for panel

    #plot target
    fig,ax = target.quick_plot()
    fig.suptitle("%d: %s" % (i,p))
    fig.show()

    #add to header
    image.header.add_panel(target)

    #save
    outpath = io.matchHeader(p)[0]
    io.saveHeader(outpath, image.header)<jupyter_output><empty_output><jupyter_text>If necessary, manually pick some targets<jupyter_code>assert False, "Pause here and turn your brain on! ツ"
incorrect = [0,1,2,3] # choose incorrectly identified targets to manually select<jupyter_output><empty_output><jupyter_text>First, clear incorrectly set targets from header file.<jupyter_code>for i in incorrect:
    image = io.loadWithGDAL( image_paths[i] )
    image.header.remove_panel(None) # remove panels
    outpath = io.matchHeader(image_paths[i])[0]
    io.saveHeader(outpath, image.header)<jupyter_output><empty_output><jupyter_text>If targets do exist in scene, manually select them. Skip this step if no targets exist.<jupyter_code>targets = []
for i in incorrect:
    
    image = io.loadWithGDAL( image_paths[i] ) #load image
    target = Panel(M,image,method='manual',bands=hylite.RGB) # select panel
    
    #add to header
    image.header.add_panel(target)

    #save
    outpath = io.matchHeader(image_paths[i])[0]
    io.saveHeader(outpath, image.header)
    
    targets.append(target) # store for plotting
#plot targets
%matplotlib inline
for i,t in enumerate(targets):
    #plot target
    fig,ax = t.quick_plot()
    fig.suptitle("%d: %s" % (incorrect[i],image_paths[incorrect[i]]))
    fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.100029163021289, 'fraction_numerical': 0.029454651501895596, 'mean_word_length': 5.270566727605119, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '4105', 'license': 'MIT', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1145, 'n_words': 275, 'path': 'template_notebooks/Processing/Terrestrial/3_identify_calibration_targets.ipynb', 'repo_name': 'sandralorenz268/hylite', 'size': '3429'}