Skip to content

Quick Start: complete cranberry analysis running in minutes.

Created by: María A. Torres-Meraz; March, 2026

PyPI

Requirements: Traitly installed (Installation Guide).

Sample images

You can download sample cranberry images here to follow along. For fruits with a more complex internal structure (e.g., tomato, orange, or cucumber), explore the Locule Segmentation tutorial.


Internal analysis

Use FruitInternalAnalyzer when your images contain visible locules (internal structure).

from traitly.fruit_phenotyping import FruitInternalAnalyzer

analyzer = FruitInternalAnalyzer("my_image.jpg")
analyzer.load_image()
analyzer.setup_measurements()
analyzer.generate_fruit_mask()
analyzer.detect_fruits()

# Morphological and color analysis
analyzer.analyze_morphology()
analyzer.analyze_color()

# Save results → returns a CSV and an annotated image
analyzer.results.save_all()

# Optionally, save the parameters used in the session
analyzer.save_parameters()

External analysis

Use FruitExternalAnalyzer for whole-fruit analysis (without locule or other internal structure segmentation).

from traitly.fruit_phenotyping import FruitExternalAnalyzer

analyzer = FruitExternalAnalyzer("my_image.jpg")
analyzer.load_image()
analyzer.setup_measurements()
analyzer.generate_fruit_mask()
analyzer.detect_fruits()

# Morphological and color analysis
analyzer.analyze_morphology()
analyzer.analyze_color()

# Save results → returns a CSV and an annotated image
analyzer.results.save_all()

# Optionally, save the parameters used in the session
analyzer.save_parameters()

Batch processing

Process an entire folder of images automatically.

# Internal analysis
from traitly.fruit_phenotyping import FruitInternalAnalyzer

analyzer = FruitInternalAnalyzer("PATH_FOLDER/")
analyzer.analyze_folder(
    folder_path="my_images/",
    output_path="results/",
    analyze_morphology=True,
    analyze_color=True,
    json_path="path/file.json"  # Optional, useful for defining parameters
)

# External analysis
from traitly.fruit_phenotyping import FruitExternalAnalyzer

analyzer = FruitExternalAnalyzer("PATH_FOLDER/")
analyzer.analyze_folder(
    folder_path="my_images/",
    output_path="results/",
    analyze_morphology=True,
    analyze_color=True,
    json_path="path/file.json"  # Optional, useful for defining parameters
)

This generates a folder called results/ with:

  • morphology_results.csv (if analyze_morphology=True)
  • color_results.csv (if analyze_color=True)
  • *_processed.jpg for each successfully analyzed image
  • session_report.txt
  • error_report.txt (only if any image failed)

What's next?