PeelColor LAB thresholds are hardcoded for green/yellow peel and cannot score blush apple images
Summary
The LAB thresholds in get_green_yellow_values are hardcoded to isolate green/yellow pixels:
threshold_2 = np.logical_and((lab_img[:, :, 1] > 0), (lab_img[:, :, 1] < 128)) # green side only
threshold_3 = np.logical_and((lab_img[:, :, 2] > 128), (lab_img[:, :, 2] < 255)) # yellow side only
This works well for green/yellow pears and the shade side of apples, but sun-side images of blush apples have predominantly positive a values (red side) and fail both thresholds entirely, producing no scoreable pixels.
Observed behavior
When running color analysis on Granny-segmented blush apple images, sun-side (A) images consistently produced no score. LAB analysis of the actual pixel values confirmed the issue — the a channel ranged from 119–181 (spanning both sides of the 128 midpoint), but threshold_2 only accepts values < 128, rejecting the majority of fruit pixels.
The function name get_green_yellow_values reflects this limitation — it was designed specifically for green/yellow fruit.
Suggested enhancement
Expose the LAB thresholds as configurable parameters so users can adjust them for different fruit types, or provide named presets (e.g. green_yellow_pear, blush_apple_shade_side). This would allow Granny to score a wider range of fruit without hardcoded assumptions about peel color.
Alternatively, the analysis could detect when no pixels pass the thresholds and warn the user that the image may be outside the expected color range for this analysis module, rather than silently failing.
Context
This was discovered while using Granny to score WA 64 blush apples using the same color card reference used for green/yellow pears. Shade-side (B) images scored correctly; sun-side (A) images produced no scoreable pixels due to this threshold limitation.
PeelColor LAB thresholds are hardcoded for green/yellow peel and cannot score blush apple images
Summary
The LAB thresholds in
get_green_yellow_valuesare hardcoded to isolate green/yellow pixels:This works well for green/yellow pears and the shade side of apples, but sun-side images of blush apples have predominantly positive
avalues (red side) and fail both thresholds entirely, producing no scoreable pixels.Observed behavior
When running color analysis on Granny-segmented blush apple images, sun-side (A) images consistently produced no score. LAB analysis of the actual pixel values confirmed the issue — the
achannel ranged from 119–181 (spanning both sides of the 128 midpoint), butthreshold_2only accepts values < 128, rejecting the majority of fruit pixels.The function name
get_green_yellow_valuesreflects this limitation — it was designed specifically for green/yellow fruit.Suggested enhancement
Expose the LAB thresholds as configurable parameters so users can adjust them for different fruit types, or provide named presets (e.g.
green_yellow_pear,blush_apple_shade_side). This would allow Granny to score a wider range of fruit without hardcoded assumptions about peel color.Alternatively, the analysis could detect when no pixels pass the thresholds and warn the user that the image may be outside the expected color range for this analysis module, rather than silently failing.
Context
This was discovered while using Granny to score WA 64 blush apples using the same color card reference used for green/yellow pears. Shade-side (B) images scored correctly; sun-side (A) images produced no scoreable pixels due to this threshold limitation.