Skip to content

An algorithm that automates the detection of shelterbelts 🌳 in croplands using high resolution aerial images as inputs. Placed 3rd πŸ† in the CanDev hackathon!

Notifications You must be signed in to change notification settings

shrimeichock/Tree-Identification-Algorithm

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tree-Identification-Algorithm

Competed against 90 teams and placed 1st πŸ₯‡ in the Agriculture and Agri-food Canada (AAFC) challenge and 3rd πŸ† overall in the CanDev Data Challenge hackathon!

Task

We need your help to develop an algorithm to identify and extract the tree crowns and/or a row of trees in and around Canadian croplands. Trees in croplands serve as sinks of carbon and play a significant role in mitigating climate change. We are interested in monitoring the changes in tree distribution to quantify carbon losses or gains in croplands.

Installation Steps

  1. Download Anaconda: https://www.anaconda.com/products/individual

  2. In the Anacona Prompt, enter the following commands:

    Create a python environment

    conda create -n pyEnv python=3.9
    conda activate pyEnv
    

    Install libraries

    conda install -c conda-forge opencv
    conda install -c conda-forge matplotlib
    conda install -c conda-forge spyder
    

    Launch Spyder:

    spyder
    
  3. Download or clone this repository to run the source code on spyder.

Input Image Requirements

  1. Use a PNG image for more accurate results.
  2. Image must be of a 64 hectare (800m by 800m) plot of land.
  3. Hue will need to be adjusted according to the image (Example images and hues can be found in the test_image directory).

How to Run the code

In TreeDetectionAlgorithm.py:

  • update img = cv2.imread("image.PNG") with the image filename/filepath. (For example img = cv2.imread("test-images\OnePlot.PNG"))
  • adjust lower_color = np.array([40, 20, 0]) with the corresponding Hue (the first number)

Run the program.

Output

The program outputs:

  • an image with tree areas surrounded by either green or red
  • the final area (in both pixels and hectares)
  • the percentage of the final tree area

The areas in green are less than 1 hectare, which and are included in the final area.

The areas in red are larger than 1 hectare, which are not included in the final area.

Example Output

Size of image in pixels: 1062 x 1039
Area of trees in pixels: 53451.5
Area of trees in hectares: 3.100272063714748
Percentage of area covered by trees: 4.84 %

Contributors

  • Shrimei Chock
  • Maisha Abdullah
  • Thanuja Sivaananthan

Sources

About

An algorithm that automates the detection of shelterbelts 🌳 in croplands using high resolution aerial images as inputs. Placed 3rd πŸ† in the CanDev hackathon!

Topics

Resources

Stars

Watchers

Forks

Languages

  • Python 100.0%