{
  "version": 1,
  "group": "image-sampling",
  "description": "Deterministic RGBA image sampling fixtures for exact pixels, clipped averaging regions, transparent-pixel handling, and palette bucket extraction.",
  "cases": [
    {
      "id": "large-camera-image-uses-exact-tiled-source",
      "operation": "imageSamplingPlan",
      "dimensions": { "width": 6768, "height": 4512 },
      "expected": {
        "width": 6768,
        "height": 4512,
        "pixelCount": 30537216,
        "decodedRgbaBytes": 122148864,
        "strategy": "tiled-source",
        "preservesSourcePixels": true
      },
      "regression": "A common 30.5 MP camera image must remain valid and use exact source tiles instead of being rejected or allocating a second full-resolution canvas."
    },
    {
      "id": "full-canvas-budget-boundary",
      "operation": "imageSamplingPlan",
      "dimensions": { "width": 5000, "height": 4000 },
      "expected": {
        "width": 5000,
        "height": 4000,
        "pixelCount": 20000000,
        "decodedRgbaBytes": 80000000,
        "strategy": "full-canvas",
        "preservesSourcePixels": true
      }
    },
    {
      "id": "exact-center-pixel",
      "operation": "sampleRgbaImage",
      "image": {
        "width": 3,
        "height": 3,
        "rgba": [
          255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255,
          255, 255, 255, 255, 0, 0, 0, 255, 128, 128, 128, 255,
          255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255
        ]
      },
      "sample": { "x": 1, "y": 1, "sampleSize": 1 },
      "expected": {
        "bounds": { "left": 1, "top": 1, "width": 1, "height": 1 },
        "rgb": { "r": 0, "g": 0, "b": 0 },
        "alpha": 255,
        "hex": "#000000",
        "sampledPixelCount": 1
      }
    },
    {
      "id": "three-by-three-center-average",
      "operation": "sampleRgbaImage",
      "image": {
        "width": 3,
        "height": 3,
        "rgba": [
          255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255,
          255, 255, 255, 255, 0, 0, 0, 255, 128, 128, 128, 255,
          255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255
        ]
      },
      "sample": { "x": 1, "y": 1, "sampleSize": 3 },
      "expected": {
        "bounds": { "left": 0, "top": 0, "width": 3, "height": 3 },
        "rgb": { "r": 128, "g": 128, "b": 128 },
        "alpha": 255,
        "hex": "#808080",
        "sampledPixelCount": 9
      },
      "roundingContract": "Each channel is averaged using full-precision sums, then rounded once to the nearest integer."
    },
    {
      "id": "edge-average-clips-to-image-bounds",
      "operation": "sampleRgbaImage",
      "image": {
        "width": 3,
        "height": 3,
        "rgba": [
          255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255,
          255, 255, 255, 255, 0, 0, 0, 255, 128, 128, 128, 255,
          255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255
        ]
      },
      "sample": { "x": 0, "y": 0, "sampleSize": 3 },
      "expected": {
        "bounds": { "left": 0, "top": 0, "width": 2, "height": 2 },
        "rgb": { "r": 128, "g": 128, "b": 64 },
        "alpha": 255,
        "hex": "#808040",
        "sampledPixelCount": 4
      }
    },
    {
      "id": "oversized-region-clips-to-whole-image",
      "operation": "sampleRgbaImage",
      "image": {
        "width": 3,
        "height": 3,
        "rgba": [
          255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255,
          255, 255, 255, 255, 0, 0, 0, 255, 128, 128, 128, 255,
          255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255
        ]
      },
      "sample": { "x": 2, "y": 2, "sampleSize": 5 },
      "expected": {
        "bounds": { "left": 0, "top": 0, "width": 3, "height": 3 },
        "rgb": { "r": 128, "g": 128, "b": 128 },
        "alpha": 255,
        "hex": "#808080",
        "sampledPixelCount": 9
      }
    },
    {
      "id": "palette-extraction-skips-transparent-pixels",
      "operation": "extractPaletteBuckets",
      "image": {
        "width": 2,
        "height": 2,
        "rgba": [
          255, 0, 0, 255,
          255, 0, 0, 255,
          0, 0, 255, 255,
          0, 255, 0, 0
        ]
      },
      "options": {
        "pixelStep": 1,
        "bucketSize": 16,
        "neutralSpread": 10,
        "neutralStep": 16,
        "mergeNeutrals": true
      },
      "expected": {
        "totalSamples": 3,
        "buckets": [
          [2, 510, 0, 0],
          [1, 0, 0, 255]
        ]
      },
      "alphaContract": "Pixels below the extraction alpha threshold do not affect sample totals or palette buckets."
    },
    {
      "id": "palette-extraction-is-deterministic",
      "operation": "extractPaletteBuckets",
      "image": {
        "width": 4,
        "height": 1,
        "rgba": [
          51, 102, 153, 255,
          51, 102, 153, 255,
          237, 28, 36, 255,
          237, 28, 36, 255
        ]
      },
      "options": {
        "pixelStep": 1,
        "bucketSize": 16,
        "neutralSpread": 10,
        "neutralStep": 16,
        "mergeNeutrals": true
      },
      "expected": {
        "totalSamples": 4,
        "buckets": [
          [2, 102, 204, 306],
          [2, 474, 56, 72]
        ],
        "repeatRunsEqual": true
      },
      "invariant": "Repeated extraction from identical bytes and options produces structurally identical buckets in stable order."
    }
  ]
}
