{"record":{"id":"fba2036108e353b7","repo":"Hmbown/CodeWhale","slug":"no-navy-hero-whale-found-in-the-founder-sheet","errorCode":null,"errorMessage":"no navy hero whale found in the founder sheet","messagePattern":"no navy hero whale found in the founder sheet","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/brand/braille-mark.py","lineNumber":103,"sourceCode":"        int(band[1] * width),\n        int(band[2] * height),\n        int(band[3] * height),\n    )\n\n\ndef hero_coverage(image: Image.Image) -> tuple[int, int, list[list[float]]]:\n    \"\"\"Navy-darkness coverage of the hero whale crop, each in 0..1.\"\"\"\n    width, height = image.size\n    x0, x1, y0, _ = band_box(image, HERO_BAND)\n    pixels = image.load()\n    xs, ys = [], []\n    for y in range(y0, int(HERO_BAND[3] * height)):\n        for x in range(x0, x1):\n            if is_navy(pixels[x, y]):\n                xs.append(x)\n                ys.append(y)\n    if not xs:\n        raise SystemExit(\"no navy hero whale found in the founder sheet\")\n    box = (\n        max(0, min(xs) - HERO_MARGIN),\n        max(0, min(ys) - HERO_MARGIN),\n        min(width, max(xs) + HERO_MARGIN + 1),\n        min(height, max(ys) + HERO_MARGIN + 1),\n    )\n    crop = image.crop(box)\n    cover = crop.load()\n    cw, ch = crop.size\n    coverage = []\n    for y in range(ch):\n        row = []\n        for x in range(cw):\n            r, g, b = cover[x, y]\n            row.append(max(0.0, min(1.0, (180.0 - (r + g + b) / 3.0) / 120.0)))\n        coverage.append(row)\n    print(f\"// hero whale box {box[0]},{box[1]}-{box[2]},{box[3]}\", file=sys.stderr)\n    return cw, ch, coverage","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/brand/braille-mark.py#L85-L121","documentation":"`hero_coverage()` scans the hero band of the founder sheet for pixels matching `is_navy()` (blue-dominant dark pixels) to locate the whale artwork. If no navy pixel is found anywhere in the band, the whale cannot be located and this SystemExit is raised.","triggerScenarios":"`main()` calls `hero_coverage()`; the nested scan over the HERO_BAND region finds zero pixels satisfying `b > 60 and b > r + 25 and r < 110 and g < 150` at scripts/brand/braille-mark.py:103, so `xs` is empty.","commonSituations":"The sheet was re-exported with different colors (e.g. whale rendered in black, teal, or with alpha/anti-aliasing that shifts RGB); the raster was converted to grayscale or CMYK and flattened differently; the hero artwork moved outside the fractional HERO_BAND after a layout change.","solutions":["Sample the whale's pixel color: open the image, inspect RGB values where the whale is, and compare against is_navy's thresholds","Adjust the is_navy thresholds (or HERO_BAND fractions) in braille-mark.py to match the actual artwork colors","Re-export the founder sheet with the original navy whale color and layout","Ensure the image is converted to RGB (load_sheet already does `.convert(\"RGB\")`) and that the whale sits within the hero band"],"exampleFix":"// before (palette changed to teal)\ndef is_navy(pixel):\n    r, g, b = pixel\n    return b > 60 and b > r + 25 and r < 110 and g < 150\n// after (loosen to match new palette)\ndef is_navy(pixel):\n    r, g, b = pixel\n    return b > 50 and b > r + 15 and r < 130 and g < 170","handlingStrategy":"validation","validationCode":"from PIL import Image\nimg = Image.open(\"brand/codewhalemarkfinal.png\").convert(\"RGB\")\nw, h = img.size\npx = img.load()\nx0, y0 = int(0.0 * w), int(0.0 * h)\nfound = any(\n    (lambda p: p[2] > 60 and p[2] > p[0] + 25 and p[0] < 110 and p[1] < 150)(px[x, y])\n    for y in range(y0, h) for x in range(x0, w)\n)\nassert found, \"no navy hero pixels anywhere in sheet; check palette/hero band\"","typeGuard":null,"tryCatchPattern":"try:\n    main()\nexcept SystemExit as e:\n    if \"no navy hero whale\" in str(e):\n        raise SystemExit(\"re-export sheet with the navy whale inside the hero band, or adjust is_navy thresholds\")","preventionTips":["Sample artwork colors after any re-export and compare against is_navy thresholds","Keep the whale inside the fractional HERO_BAND of the sheet layout","Always export to RGB-capable formats (avoid grayscale/CMYK flattening)","Add a quick palette check to the design export pipeline"],"tags":["python","image-processing","detection-failed","branding-script"],"backgroundTag":"empty-result-set","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}