open-forest-observatory / tree-detection-framework

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Added preprocessing section for chipping tiles from orthomosaic image (work-in-progress) #1

Closed amrithasp02 closed 2 months ago

amrithasp02 commented 2 months ago

In chip_ortho.py:

  1. CustomOrthoDataset is a child class of RasterDataset to load ortho images provided by the user

  2. chip_orthomosaics() :

    • creates a dataset instance
    • sets the units accordingly to pixels/meters (CRS)
    • if tiles need to be saved -> create dataloader with the GridGeoSampler to ensure contiguous tiles. Save tiles as PNG images with the ToPILImage() function from torchvision that converts tensor to PIL images.
    • if tiles need to be visualized -> create dataloader with the RandomGeoSampler to visualize 'n' number of randomly (I though it's better to use random tiles for inspection rather than contiguous ones. Let me know if it is better to stick to just one type of Sampler.)

Further modifications to add:

  1. Storing the metadata of tiles (CRS, transforms etc.)
  2. Incorporate tile size/%overlap input argument
  3. Regex specification for selecting files from the path
amrithasp02 commented 2 months ago

Updated:

  1. Changed size/stride to a float parameter
  2. Used enumerate for tile count
  3. Used Path object to manipulate paths
  4. Changed to a single dataloader for saving and visualizing
  5. meters-based CRS bug: I have implemented a function for converting the raster data to the reprojected CRS. If there is a simpler way to do this, please let me know. Note: This function has not yet been tested since I didn't have a lat-lon raster file with me.
  6. Formatted, added docstrings
  7. Added functionality to saved tile metadata as JSON files in the same path
  8. Added size/%overlap input parameter

@russelldj

amrithasp02 commented 2 months ago

Updates:

  1. Added type annotations
  2. Moved the visualization step out of the tile saving loop. Separated both functionalities
  3. Meters-based CRS projection of the raster in case of geographic CRS is now done by the dataloader itself (line 71).
  4. Created ToPILImage() outside the loop

@russelldj