Skip to content

evanmarlo/green-pixel-analysis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Written by Jakob Johnson for the USU Crop Physiology Laboratory.

This program analyzes images and counts the number of green pixels in the image. It reads image files from the chosen directory and outputs a csv containing summary information to the parent directory.

The image files in test-img are given as sample images to demonstrate the code.

Used in "Substituting Far-Red for Traditionally Defined Photosynthetic Photons Results in Equal Canopy Quantum Yield for CO2 Fixation and Increased Photon Capture During Long-Term Studies: Implications for Re-Defining PAR" by Shuyang Zhen and Bruce Bugbee

Usage

Requires Python 3.x.x

GUI in Windows/macOS

Install dependancies numpy and Pillow using PowerShell/Terminal with the commands

pip install numpy
pip install Pillow

To run the program, either open main.py with Python or in PowerShell/Terminal using

python `.\path\to\directory\main.py`

Note, for macOS you'll need to use python3 instead of python

Select a directory in the popup window and click 'Run Analysis'. The terminal window gives information about the running program.

The 'Create Analyzed Images' checkbox lets you save an image showing where the program detected green pixels. This option slows down analysis.

The 'Fuzz Factor' slider determines the algorithm's green sensitivity. Increase it if necessary to eliminate background noise.

Linux Dependency Installation

Install numpy and Pillow using the terminal commands

sudo apt install python3-numpy
sudo apt install python3-pil

Without GUI

Follow the above steps to install the dependencies, then in your python program, import the gpix.py file and run the analysis with

gpix.countPix('file/path/to/images', save = T/F, fuzzFactor).writeCsv('/dir/to/write/to/')

countPix() returns an object that contains summary information about the analyzed photos. Run its .writeCsv() method to export the stored data as a .csv file.

Example

Reading the file RB 300 FR 50 June 6 630pm.jpg, image returns the image RB 300 FR 50 June 6 630pm-ANALYZED.jpg, image and the summary statistics,

Image Name Total Green Pixels Percent of Total
RB 300 FR 50 June 6 630pm 940635 0.313545

On a second pass, the program will ignore the *-ANALYZED.jpg file and overwrite the csv table.

Settings up crontabs

Install libcamera with the following command

sudo apt install libcamera-apps

About

Green Pixel Counting for Plant Images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.8%
  • Tcl 10.1%
  • Shell 0.1%