Skip to content

3. Script Descriptions: G1_imageProducts

burritobrittany edited this page Jul 17, 2020 · 3 revisions
  • G1_imageProducts

    • Description:

    This function generates statistical image products for a given set of images and corresponding extrinsics/intrinsics. The statistical image products are the timex (average intensity), brightest (maximum intensity), variance (variance in intensity), and darkest (minimum intensity). If specified, rectified imagery for each image/frame can be produced and saved as an png file. Rectified images and image products can be produced in world or local coordinates if specified in the grid provided by D_gridGenExampleRect. This can function can be used for a collection with variable (UAS) and fixed intrinsics in addition to single/multi camera capability.

    Note: Function can either have a temporally constant elevation grid with spatially varying Z or a spatially constant elevation grid with a temporally varying elevation value. The code needs to be modified to have both. If zVariable is non-empty, this will take precedent and make a spatially constant but temporally varying Z grid to rectify to

    This function is to be run sixth or fifth in the progression for fixed and UAS collections.

    The user input of the code is prescribed for UASDemoData. However, one can uncomment lines in Section 5 for the FixedMultiCamDemoData.

    • Input:

    Input is entered by user into the script in Sections 1-5.

    Section 1: Saving Information

    Variable Description
    oname Output string for the basename for the georectified images to be saved as.
    odir Output filepath where the SCP mat file will be saved.
    outputFlag Flag if you would like individual frames rectified and saved in the odir. 1= yes, output individual frames. 0= no, only output image products.

    Section 2: Collection Information

Variable Description
imageDirectory The directory where the collection images are stored. Note, for UAS or collects with variable extrinsics solved in F, The images should be ordered in the same order listed in imageNames F_variableExtrinsicSolutions. For variable IOEO, the code will attempt to rectify all images in in the folder, if the number of images do not match it will crash. If the order does not match, they will be rectified incorrectly. For fixed IOEO, the code will rectify all images in the folder regardless with the same IOEO.

Note for multi-camera collections, each camera will require a separate imagedirectory with the order of the images the same across all folders. It is up to the user to name files correctly so that images at the same index are simultaneous.

ioeopath Filepath of the saved CIRN IOEO calibration results produced by C_singleExtrinsicSolution or F_variableExtrinsicSolutions . If not produced by C or F, minimum variables are listed below.
intrinsics A [1x11] vector describing the focal lengths and distortion of the camera/lens combination. Distortion coefficients are defined by [3] and defined in Section 6.
extrinsics A [Tx6] vector describing the camera pose and position in WORLD coordinates (whatever coordinate system GCPs were entered in). T is the number of frames extrinsics are solved for and number of images in imageDirectory. Extrinsic values are defined in Section 6 along with coordinate systems. The extrinsics should correspond to the images as ordered by matlab as was solved for in F.
t A Tx1 vector of timing of each frame in datenum format produced by F_variableExtrinsicsSolutions. This is not necessarily required. User can specify it manually in Section 4. If t is not specified or loaded in the ioeopath mat file, vector is just numbers 1,2,3, etc. T should be the number of images in imageDirectory
    Section 3: Grid Information
Variable Description
gridpath Filepath of the saved rectification grid created in D_gridGenExampleRect. Minimum required variables are listed below. Local values only required if localFlag==1
X NxM grids in World coordinates where N is the number of rows (direction of varying Y) and M is the number of columns (direction of varying X). Grid needs to be in meshgrid format and be in same World coordinates as extrinsics in ioeopath
Y
Z
localOrigin Origin of new local coordinate system in world coordinates. should be in the same coordinate system of GCPs (worldCoord).
localAngle relative angle between the new (local) X axis and old (World) X axis, positive counter-clockwise from the old (world) X. Units are degrees.
localX NxM grids in rotated Local coordinates (according to localAngle and localOrigin) where N is the number of rows (direction of varying Y) and M is the number of columns (direction of varying X).
localY
localZ
worldCoord String of description of the World coordinate system for IOEO specified ioeopath.
localFlag Enter if the user prefers local (localFlag==1) or world (localFlag==0) coordinates. Not if localFlag==1, localAngle, localOrigin, and localX,Y,Z in the ioeopath must all be non-empty.

    Section 4: Manual Entry of Time and Elevation

    Variable Description
    t A Tx1 vector of timing of each frame in datenum format. If t is not specified or loaded in the ioeopath mat file (as if produced from F), vector is just numbers 1,2,3, etc. T should be the number of images in imageDirectory.
    zVariable A Tx1 vector of elevations in world coordinates and units. f a Fixed station, most likely images will span times where Z is no longer constant. We have to account for this in our Z grid. To do this, enter a z vector below that is the same length as t. For each frame, the entire z grid will be assigned to this value. If UAS or not desired, leave empty. It is assumed elevation is constant during a short collect.

    Section 5: Mulit-Camera Demo

    Uncomment this section for the multi-camera demo. ImageDirectory and ioeopath should be entered as cells, with each entry representing a different camera. It is up to the user that entries between the two variables correspond. Extrinsics between all cameras should be in the same World Coordinate System. Note that no new grid is specified, the cameras and images are all rectified to the same grid and time varying elevation. Also it is important to note for imageDirectory, each camera should have its own directory for images. The number of images in each directory should be the same (T) as well as ordered by MATLAB so images in the same order are simultaneous across cameras (i.e. the third image in c1 is taken at t=1s, the third image in c2 is taken at t=1s, etc).

    • Output:

    A .mat file saved as oname_gridmeta.mat in odir. Will contain following variables; variables left blank are defined in the user input.

Variable Description
rectMeta Structure with metadata about output rectifications. Fields are listed below. Those left blank are the same entered in the input sections.
ioeopath
imageDirectory
gridPath
imageNames Filenames of all images rectified.
t
zVariable
worldCoord
localFlag All only if localFlag==1
localAngle
localOrigin
X Flipped grids corresponding to rectified images. Before saved as an image, the image is flipped using flipUD so the image looks correct. (This is due to the image coordinate system, see section 6. Thus, so XYZ corresponds to the same pixels, we filp the grids as well for correct plotting. Values are local or world depending on localFlag.
Y
Z
    Three pngs saved as oname_timex.png, oname_dark.png and oname_bright.png in odir. In addition, these are displayed in a Figures (Figure 10).


Figure 10: Example ensemble output of G1_imageProducts for uasDemoData in a local rotated coordinate system.

    If outputFlag=1, T geo-rectified images in odir with the filename oname_(time or index).png. If time, time is referenced in epoch time in milliseconds. World or local coordinates is dependent on input localFlag value.

    • Required Core Sub-Functions:

      • imageRectification
      • cameraSeamBlend
      • xyz2DistUV
      • distortUV
      • intrinsicsExtrinsics2P
      • localTransformExtrinsics
      • localTransformPoints
      • plotRectification
Clone this wiki locally