Skip to content

This script processes an image to detect and estimate the number of kakis (persimmons) by identifying the common orange areas using a Gaussian fit method with least squares estimation.

License

Notifications You must be signed in to change notification settings

toooku/count_kaki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaki Detection Script

This script processes an image to detect and estimate the number of kakis (persimmons) by identifying the common orange areas using a Gaussian fit method with least squares estimation.

Overview

The script performs the following steps:

  • Reads an image of kakis.
  • Converts the image to the HSV color space.
  • Applies a median blur to reduce noise.
  • Masks the image to isolate the orange color of the kakis.
  • Dilates the mask to ensure kakis are properly highlighted.
  • Extracts the kakis from the original image using the mask.
  • Finds contours of the masked kakis.
  • Estimates the number of kakis based on the most common area obtained from a Gaussian fit of the area histogram.
  • Draws contours around the detected kakis and saves the output images.

Requirements

To run this script, you'll need Python installed on your system along with the following libraries:

  • numpy
  • opencv-python
  • scipy

You can install these libraries using pip with the following command:

pip install numpy opencv-python scipy

Usage

To use the script, follow these steps:

  1. Place your image of kakis in the ./img/ directory and name it kaki.JPG.
  2. Run the script with the command python kaki_detection.py.
  3. The script will output two images:
    • masked_kaki.jpg: Shows the kakis with the mask applied.
    • contoured_kaki.jpg: Displays the original kakis with contours drawn around them.
  4. The estimated count of kakis will be printed to the console.

Files

  • kaki_detection.py: The main script file.
  • ./img/kaki.JPG: Input image file (you need to provide this).
  • ./img/masked_kaki.jpg: Output image with kakis masked.
  • ./img/contoured_kaki.jpg: Output image with contours drawn around kakis.

This document was generated by an AI model from OpenAI.

About

This script processes an image to detect and estimate the number of kakis (persimmons) by identifying the common orange areas using a Gaussian fit method with least squares estimation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages