Jun 07, 2026

Standardized Imaging and Preprocessing Pipeline for Sugarcane Variety Classification

Standardized Imaging and Preprocessing Pipeline for Sugarcane Variety Classification
  • 1School of Technology, University of Campinas (UNICAMP)
  • workspace_JulioLemos
Icon indicating open access to content
QR code linking to this content
Protocol CitationJulio Cesar de Lemos, André Franceschi de Angelis 2026. Standardized Imaging and Preprocessing Pipeline for Sugarcane Variety Classification. protocols.io https://dx.doi.org/10.17504/protocols.io.6qpvr1edpgmk/v1
Manuscript citation:
Under review at PLOS ONE
License: This is an open access  protocol  distributed under the terms of the  Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: June 05, 2026
Last Modified: June 07, 2026
Protocol  Integer ID: 318610
Keywords: Sugarcane, YOLOv8, Computer Vision, Deep Learning, Image Preprocessing, Phenotyping, Cultivar Classification, preprocessing pipeline for sugarcane variety classification, image acquisition of sugarcane stalk, benchmarking sugarcane variety identification, sugarcane variety classification, sugarcane variety identification, sugarcane stalk, standardized image acquisition, subsequent image preprocessing pipeline, variety classification, standardized imaging, opencv for background removal, preprocessing pipeline, background removal
Abstract
This protocol describes the standardized image acquisition of sugarcane stalks under controlled lighting conditions and the subsequent image preprocessing pipeline using OpenCV for background removal and variety classification. This method supports the study: 'Benchmarking sugarcane variety identification under controlled conditions'.
Image Attribution
Image created by the authors.
Materials
Camera: Canon EOS R8 mirrorless digital camera (24.2-megapixel) with EF 24-50 mm f/4.5-6.3 IS STM lens.
Lighting: Two softboxes and an integrated 5000K LED strip.
Hardware/Mount: Fixed tripod with height adjustment.
Background: Uniform matte black flat surface.
Software: Python 3.8+, OpenCV 4.7.0, Ultralytics YOLOv8. The custom preprocessing scripts are publicly available at: https://github.com/Juliodelemos/sugarcane-variety-classification-yolov8
Samples: Sugarcane billets (approx. 30 cm length) of varieties IAC-5503, CTC-1007, RB-7515, RB-5375.
Safety warnings
The raw and preprocessed sugarcane image dataset generated by strictly following this protocol is publicly available and deposited at REDU under the DOI: https://doi.org/10.25824/redu/S1OJFI
Steps
Sample Preparation: Section the sugarcane culms into billets with a standardized length of approximately 30 cm using a sharp, sanitized machete. Perform swift, transverse cuts to minimize tissue damage and fraying at the edges. Purposefully exclude leaves to focus exclusively on the specific morphological characteristics of the stem.
Imaging Setup: Arrange the billets individually on a uniform matte black flat surface to provide high contrast with the dark background.
Camera Setup: Mount the Canon EOS R8 camera on a fixed tripod. Set the distance between the camera's focal plane and the billet base to exactly 56 cm, ensuring the camera is mounted exactly perpendicular (90 degrees) to the flat surface to prevent perspective distortion and ensure framing consistency.
Lighting Configuration:Position the two softboxes at approximately 45-degree angles on either side of the sample to provide the primary source of soft, diffuse light. Use the integrated 5000K LED strip to provide additional homogeneous light from the sides. Ensure ambient room lighting is turned off to isolate the controlled light sources and minimize specular reflections.
Image Acquisition: Capture high-resolution images (6000 x 4000 pixels) in JPG format using manual camera settings (e.g., fixed ISO, aperture, and shutter speed) to ensure exposure consistency across all samples. Trigger the camera remotely using a smartphone and monitor via a dedicated video screen to eliminate physical vibrations.
Preprocessing - Conversion: Convert raw images to grayscale to facilitate thresholding.
Preprocessing - Segmentation: Convert the raw images to grayscale and apply a Gaussian blur (using a 5x5 kernel) to smooth the image and reduce noise. Following this, apply binary thresholding (e.g., using a threshold value of 150) to generate an initial binary mask separating the sugarcane stalk from the dark background.
Preprocessing - Polygonal Cropping and Masking: Use contour detection (cv2.findContours) on the binary mask and filter out noise by enforcing a minimum area threshold (e.g., 130,000 pixels). Select the largest remaining contour and approximate its shape as a polygon using the Douglas-Peucker algorithm (cv2.approxPolyDP, with epsilon set to 0.1% of the arc length). Create a precise mask from this polygon, apply it to the image (cv2.bitwise_and), crop to the bounding box, and finally add an alpha channel (cv2.COLOR_BGR2BGRA) to render the background fully transparent.
Preprocessing - Output: Export the resulting segmented images as PNG files with transparent backgrounds, preserving only the relevant morphological features.
Normalization: Resize the cropped images to 224x224 pixels using interpolation (e.g., OpenCV's INTER_AREA or INTER_LINEAR) to meet the input requirements of the YOLOv8n-cls model architecture prior to dataset partitioning.