This repository contains a technique for segmenting a set of plants and measuring their areas. Originally, this code was developed as my final project for the Digital Image Processing course, and the image included in this repository is one of many from the original dataset. However, due to limited access, I only had access to a single image. As a result, my code is designed to address the challenges of a single image. It's important to note that the solution may not perform optimally when applied to other plant images. Nevertheless, there is room for improvement, so feel free to use and implement a more general solution.
โข OpenCV
โข NumPy
- Process the image
- Use Canny Edge Detection
- Dilate the image
- Find contours in the resulting image
- Create a vector to store each area
- Use Contour Approximation
- Find the area for a closed contour
- Create a vector to store each area
- For each area, convert the measurement from pixel^2 to mm^2
- In the source image, add text to each plant indicating its index
In the image, there was a ruler that could be used to assist in measurement transformation

The results were good and significant; most plants have a concrete and feasible area. However...

However, three plants have an incorrect area. Even though the code can handle most plants, it's important to note that there are errors

For those who are reading and want to explore the code, I believe that a possible solution is to use the Otsu method to segment the plants, as the application of the threshold is automatic and efficient
For more information about the OpenCV library, please visit: OpenCV
For additional details on the NumPy library, visit: NumPy
To learn more about the Canny Edge Detection method, refer to: Canny Edge Detection
For in-depth information on Contour methods, explore: Contours