# Image Tiling Tests

**Task**: AZ-141_test_tiling
**Name**: Image Tiling Tests
**Description**: Implement E2E tests verifying GSD-based tiling for large images and tile boundary deduplication
**Complexity**: 3 points
**Dependencies**: AZ-138_test_infrastructure
**Component**: Integration Tests
**Jira**: AZ-141
**Epic**: AZ-137

## Problem

Images exceeding 1.5x model dimensions (1280x1280) must be tiled based on Ground Sample Distance (GSD) calculations. Tests must verify that tiling produces correct results with coordinates normalized to the original image, and that duplicate detections at tile boundaries are properly merged.

## Outcome

- Large image tiling confirmed with GSD-based tile sizing
- Detection coordinates normalized to original image dimensions (not tile-local)
- Tile boundary deduplication verified (no near-identical coordinate duplicates)
- Bounding box coordinates remain in 0.0-1.0 range

## Scope

### Included
- FT-P-04: Large image triggers GSD-based tiling
- FT-P-16: Tile deduplication removes duplicate detections at tile boundaries

### Excluded
- Small image detection (covered in single image tests)
- Tiling performance benchmarks (covered in performance tests)
- Tile overlap configuration beyond default (implementation detail)

## Acceptance Criteria

**AC-1: GSD-based tiling**
Given an initialized engine and a large image (4000x3000)
When POST /detect is called with altitude, focal_length, sensor_width config
Then detections are returned with coordinates in 0.0-1.0 range relative to the full original image

**AC-2: Tile boundary deduplication**
Given an initialized engine and a large image with tile overlap
When POST /detect is called with tiling config including big_image_tile_overlap_percent
Then no two detections of the same class have coordinates within 0.01 of each other (TILE_DUPLICATE_CONFIDENCE_THRESHOLD)

## Non-Functional Requirements

**Performance**
- Large image processing within 60s (tiling adds overhead)

## Integration Tests

| AC Ref | Initial Data/Conditions | What to Test | Expected Behavior | NFR References |
|--------|------------------------|-------------|-------------------|----------------|
| AC-1 | Engine warm, large-image (4000x3000), GSD config | POST /detect with large image | Detections with coords 0.0-1.0 relative to full image | Max 60s |
| AC-2 | Engine warm, large-image, tile overlap config | Check for near-duplicate detections | No same-class duplicates within 0.01 coords | Max 60s |

## Constraints

- Large image fixture must exceed 1.5x model input (1920x1920) to trigger tiling
- GSD parameters must be physically plausible for the test scenario
- Tile dedup threshold is hardcoded at 0.01 in the system

## Risks & Mitigation

**Risk 1: No detections at tile boundaries**
- *Risk*: Test image may not have objects near tile boundaries
- *Mitigation*: Verify tiling occurred by checking processing time is greater than small image; dedup assertion is vacuously true if no boundary objects
