From ac390fae3164831d87212c442b791fbd40a7ff9a Mon Sep 17 00:00:00 2001 From: AdenAthar Date: Mon, 5 Jan 2026 12:29:43 -0800 Subject: [PATCH 1/4] Add 8 new starch scale varieties and configurable text color - Added new starch scale calibrations: PURDUE, DANJOU, AMBROSIA, MINNEISKA, PINKLADY, REDDELICIOUS1980, REDDELICIOUS1990, ROYAL_GALA - Implemented configurable RGB text color parameters for segmentation visualization (text_color_r, text_color_g, text_color_b) - All new varieties processed with default threshold 172 - Total starch scales now: 17 varieties --- Granny/Analyses/Segmentation.py | 35 ++++++++++++++++++++++++++++++++- Granny/assets/starch_scales.yml | 32 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Granny/Analyses/Segmentation.py b/Granny/Analyses/Segmentation.py index 16cd2e8..15945f4 100644 --- a/Granny/Analyses/Segmentation.py +++ b/Granny/Analyses/Segmentation.py @@ -211,6 +211,36 @@ def __init__(self): self.text_thickness.setValue(3) self.text_thickness.setIsRequired(False) + self.text_color_r = IntValue( + "text_color_r", + "text_color_r", + "Red channel value for text color (0-255). Default is 0 (black).", + ) + self.text_color_r.setMin(0) + self.text_color_r.setMax(255) + self.text_color_r.setValue(0) + self.text_color_r.setIsRequired(False) + + self.text_color_g = IntValue( + "text_color_g", + "text_color_g", + "Green channel value for text color (0-255). Default is 0 (black).", + ) + self.text_color_g.setMin(0) + self.text_color_g.setMax(255) + self.text_color_g.setValue(0) + self.text_color_g.setIsRequired(False) + + self.text_color_b = IntValue( + "text_color_b", + "text_color_b", + "Blue channel value for text color (0-255). Default is 0 (black).", + ) + self.text_color_b.setMin(0) + self.text_color_b.setMax(255) + self.text_color_b.setValue(0) + self.text_color_b.setIsRequired(False) + # Sorting/grouping parameter self.row_tolerance = IntValue( "row_tolerance", @@ -277,6 +307,9 @@ def __init__(self): self.bbox_thickness, self.font_scale, self.text_thickness, + self.text_color_r, + self.text_color_g, + self.text_color_b, self.row_tolerance, ) @@ -388,7 +421,7 @@ def _extractMaskedImage(self, tray_image: Image) -> Image: (x1, y1), fontFace=cv2.FONT_HERSHEY_SIMPLEX, fontScale=self.font_scale.getValue(), - color=(255, 255, 255), + color=(self.text_color_b.getValue(), self.text_color_g.getValue(), self.text_color_r.getValue()), thickness=self.text_thickness.getValue(), ) image_instance: Image = RGBImage( diff --git a/Granny/assets/starch_scales.yml b/Granny/assets/starch_scales.yml index 632fc5e..aecc5f3 100644 --- a/Granny/assets/starch_scales.yml +++ b/Granny/assets/starch_scales.yml @@ -42,3 +42,35 @@ JONAGOLD: CORNELL: index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] rating: [0.990554095, 0.915430492, 0.822470328, 0.726896529, 0.610745795, 0.338955981, 0.150869695, 0.041547982] + +PURDUE: + index: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] + rating: [0.904324121, 0.755849937, 0.675973804, 0.411188084, 0.330359199, 0.160435085, 0.058093191] + +DANJOU: + index: [1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0] + rating: [0.671216439, 0.712379151, 0.716414141, 0.610183800, 0.561413711, 0.587651727, 0.432876712, 0.224843496] + +AMBROSIA: + index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] + rating: [0.677900982, 0.716849891, 0.706853718, 0.640881459, 0.706108586, 0.649827467, 0.529746181, 0.376089325] + +MINNEISKA: + index: [1.0, 2.0, 3.0, 4.0, 5.0] + rating: [0.947185658, 0.832543984, 0.702287118, 0.754320472, 0.828170081] + +PINKLADY: + index: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] + rating: [0.688407441, 0.638611615, 0.538377193, 0.508639595, 0.511078342, 0.362220206, 0.087586963] + +REDDELICIOUS1980: + index: [1.2, 1.5, 1.8, 2.0, 2.2, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0] + rating: [0.763414634, 0.759957672, 0.715492063, 0.724126871, 0.755778259, 0.677349957, 0.709361702, 0.766573651, 0.538233966, 0.526342798, 0.563694327, 0.334683983] + +REDDELICIOUS1990: + index: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] + rating: [0.647573029, 0.680765086, 0.645238881, 0.621514161, 0.626233592, 0.537175434, 0.496598639, 0.410324969, 0.309060403, 0.304480287, 0.566495300, 0.123042506] + +ROYAL_GALA: + index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] + rating: [0.585482385, 0.508346765, 0.595485685, 0.655133203, 0.620727075, 0.706972973, 0.699773112, 0.705987842, 0.693452218] From bf790efec46527608843f5d32b2680c5aa2bcf9e Mon Sep 17 00:00:00 2001 From: AdenAthar Date: Wed, 7 Jan 2026 10:58:16 -0800 Subject: [PATCH 2/4] Update PURDUE to default threshold 172, keep threshold 150 as comment - Changed PURDUE calibration to use default threshold 172 - Added threshold 150 data as commented alternative for comparison - All varieties now consistently use threshold 172 --- Granny/assets/starch_scales.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Granny/assets/starch_scales.yml b/Granny/assets/starch_scales.yml index aecc5f3..f73f68e 100644 --- a/Granny/assets/starch_scales.yml +++ b/Granny/assets/starch_scales.yml @@ -45,7 +45,10 @@ CORNELL: PURDUE: index: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] - rating: [0.904324121, 0.755849937, 0.675973804, 0.411188084, 0.330359199, 0.160435085, 0.058093191] + rating: [0.942025840, 0.858846162, 0.767229201, 0.564366621, 0.484868413, 0.266928900, 0.074313346] + # Threshold 150 alternative (for comparison): + # index: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] + # rating: [0.904324121, 0.755849937, 0.675973804, 0.411188084, 0.330359199, 0.160435085, 0.058093191] DANJOU: index: [1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0] From 1c74e030cfbc5028cfad1029bcacbf274324f1c1 Mon Sep 17 00:00:00 2001 From: AdenAthar Date: Wed, 21 Jan 2026 14:44:25 -0800 Subject: [PATCH 3/4] Add results/ directory to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8b5b402..d2199d5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ dist/ 06-Package *logs/ _build/ +results/ # Files *.pyc From b15b5bcc9a79adfe8af679501883f1fc503a7b6b Mon Sep 17 00:00:00 2001 From: AdenAthar Date: Fri, 23 Jan 2026 12:27:56 -0800 Subject: [PATCH 4/4] Update 8 starch scale varieties with transparent-background calibration Re-processed reference images using AI background removal (rembg) to fix pixel range detection issues caused by white/gray backgrounds. --- Granny/assets/starch_scales.yml | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Granny/assets/starch_scales.yml b/Granny/assets/starch_scales.yml index f73f68e..cc271a1 100644 --- a/Granny/assets/starch_scales.yml +++ b/Granny/assets/starch_scales.yml @@ -36,8 +36,10 @@ GRANNY_SMITH: rating: [0.920742836, 0.890332499, 0.808227909, 0.721813109, 0.595806394, 0.278299256, 0.104111379] JONAGOLD: + # Updated with transparent background images (2026-01-22) + # Note: Minor non-monotonic at indices 7.0 and 9.0 index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] - rating: [0.898336414, 0.859494456, 0.806417832, 0.742177914, 0.653981582, 0.483778570, 0.387202327, 0.284663986, 0.175593498] + rating: [0.904449699, 0.874103352, 0.836673554, 0.838637605, 0.784962049, 0.594890812, 0.701861145, 0.443807162, 0.596292231] CORNELL: index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] @@ -51,29 +53,44 @@ PURDUE: # rating: [0.904324121, 0.755849937, 0.675973804, 0.411188084, 0.330359199, 0.160435085, 0.058093191] DANJOU: + # Updated with transparent background images (2026-01-22) + # Note: Minor non-monotonic at index 3.5 index: [1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0] - rating: [0.671216439, 0.712379151, 0.716414141, 0.610183800, 0.561413711, 0.587651727, 0.432876712, 0.224843496] + rating: [0.936809998, 0.922681876, 0.872891694, 0.751986331, 0.632509641, 0.675894367, 0.385525954, 0.269095698] AMBROSIA: + # Updated with transparent background images (2026-01-22) + # Ratings averaged across A/B/C variants for each index index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] - rating: [0.677900982, 0.716849891, 0.706853718, 0.640881459, 0.706108586, 0.649827467, 0.529746181, 0.376089325] + rating: [0.938836999, 0.918713937, 0.899148039, 0.800415449, 0.743251611, 0.546193038, 0.434137897, 0.190703881] MINNEISKA: + # Updated with transparent background images (2026-01-22) + # WARNING: Still non-monotonic - source images have quality issues + # Index 6.0 missing (reference card says "apple clear of starch") index: [1.0, 2.0, 3.0, 4.0, 5.0] - rating: [0.947185658, 0.832543984, 0.702287118, 0.754320472, 0.828170081] + rating: [0.941631104, 0.906756575, 0.579645190, 0.643510650, 0.441163061] PINKLADY: + # Updated with transparent background images (2026-01-22) + # Excellent monotonic decrease index: [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] - rating: [0.688407441, 0.638611615, 0.538377193, 0.508639595, 0.511078342, 0.362220206, 0.087586963] + rating: [0.959550159, 0.699509917, 0.614671054, 0.502103609, 0.491582825, 0.311998962, 0.147608409] REDDELICIOUS1980: + # Updated with transparent background images (2026-01-22) + # Excellent monotonic decrease index: [1.2, 1.5, 1.8, 2.0, 2.2, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0] - rating: [0.763414634, 0.759957672, 0.715492063, 0.724126871, 0.755778259, 0.677349957, 0.709361702, 0.766573651, 0.538233966, 0.526342798, 0.563694327, 0.334683983] + rating: [0.930329713, 0.915044820, 0.856309558, 0.853819411, 0.792795414, 0.761423428, 0.711408319, 0.619893048, 0.495924193, 0.480951636, 0.431083558, 0.203781176] REDDELICIOUS1990: + # Updated with transparent background images (2026-01-22) + # Excellent monotonic decrease index: [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] - rating: [0.647573029, 0.680765086, 0.645238881, 0.621514161, 0.626233592, 0.537175434, 0.496598639, 0.410324969, 0.309060403, 0.304480287, 0.566495300, 0.123042506] + rating: [0.969424567, 0.945761350, 0.935346949, 0.880456871, 0.816953597, 0.736772334, 0.669650642, 0.579715970, 0.442378759, 0.320778000, 0.203632175, 0.181581181] ROYAL_GALA: + # Updated with transparent background images (2026-01-22) + # Note: Minor non-monotonic at index 3.0 index: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] - rating: [0.585482385, 0.508346765, 0.595485685, 0.655133203, 0.620727075, 0.706972973, 0.699773112, 0.705987842, 0.693452218] + rating: [0.910532554, 0.839360955, 0.928483858, 0.863534479, 0.774230735, 0.737439732, 0.568495148, 0.480588864, 0.325108538]