Commit Graph

18 Commits

Author SHA1 Message Date
c3f4126296 Update BrushCanvasView and CanvasView, add screenshots 2026-01-25 10:46:17 -05:00
9f35ea751e Fix brush tool not working after undo
- Fixed dimension mismatch between mask and display image after undo
- Mask was being created at original image size, but displayImage is at
  preview scale after undo/redo (renderPreview scales images > 2048px)
- Now create mask at actual displayImage dimensions, ensuring mask and
  image sizes match for inpainting
- Also fixed edge refinement gradient to recompute when image changes
2026-01-24 23:26:52 -05:00
83baff5efb docs: Add comprehensive README with app features and LaMa ML model details 2026-01-24 15:14:48 -05:00
eb047e27b8 Add LaMa Core ML model for AI-powered inpainting
- Add LaMaFP16_512.mlpackage (~90MB) for high-quality object removal
- Add LaMaInpainter.swift wrapper with image preprocessing and merging
- Modify InpaintEngine to use LaMa first, gradient fill as fallback
- Fix brush mask size (use scale 1.0 instead of screen scale)
- Fix LaMa output size (use scale 1.0 in merge function)
- Add model loading wait with 5 second timeout

The LaMa model provides significantly better inpainting quality compared
to the gradient fill method, especially for complex backgrounds.
2026-01-24 14:31:54 -05:00
14e2502cf4 Fix object selection, inpainting, and image display issues
- Fix object selection by correctly calculating bytesPerPixel in mask buffer
- Improve inpainting with 16-direction gradient fill and inverse-square blending
- Add 100 smoothing iterations to eliminate seam artifacts
- Increase mask dilation to 20px to exclude object edge remnants
- Fix brush tool gesture conflict - disable pan while brushing
- Fix image orientation by normalizing EXIF rotation on load

Modified files:
- MaskingService.swift: Fix pixel offset calculation for mask buffers
- Shaders.metal: Add gradient fill with 16 directions and multi-pixel sampling
- PatchMatch.swift: Use gradient fill + smoothing, add encodeGradientFill
- InpaintEngine.swift: Increase iterations to 500, patch radius to 8
- CanvasView.swift: Disable pan gesture when brush tool selected
- EditorViewModel.swift: Normalize image orientation on load
gradient-fill-in
2026-01-24 14:05:50 -05:00
7d3794767f Add more detailed logging to object detection flow 2026-01-24 13:08:30 -05:00
316db3e1eb Fix tap gesture blocked by line brush drag gesture
The DragGesture with minimumDistance: 0 for line brush mode was
consuming all touches, preventing tap detection for Object/Person/Wire
tools. Fixed by:

1. Only attaching line brush gesture when in line brush mode
2. Added conditional .if() view modifier extension
3. Added debug logging to tap gesture to track gesture flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 13:05:30 -05:00
52094862e0 Add debug logging throughout the app
Added DebugLogger utility with emoji-prefixed console output for:
- User actions (👆)
- State changes (📊)
- Processing steps (⚙️)
- Errors ()
- Image info (🖼️)

Logging added to:
- EditorViewModel: tap handling, mask operations, brush/line brush
- InpaintEngine: memory checks, Metal vs Accelerate path
- PatchMatch: texture creation and loading
- MaskingService: Vision requests
- BrushCanvasView: stroke creation and mask generation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 12:58:27 -05:00
4fbf1abb57 Fix Metal texture size mismatch in mask loading
Scale mask and image to texture dimensions when loading into Metal
textures, fixing crash when brush mask has different dimensions
than the source image.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 12:54:27 -05:00
ab46586ece Complete remaining high-priority features
- Edge refinement: Wire toggle to actually snap brush strokes to edges
  using Sobel gradient analysis in EdgeRefinement.swift
- Brush preview circle: Show visual cursor following finger during drawing
- PHAsset storage: Capture localIdentifier for Photo Library imports
- Low-confidence mask warning: Show "Does this look right?" for uncertain
  detections based on mask coverage and edge sharpness analysis
- Fix Swift 6 concurrency warnings with nonisolated static methods

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 12:45:08 -05:00
99faa068f3 Add person/wire removal features and accessibility support
- Person removal: select all people option, mask dilation, brush refinement
- Wire removal: line brush fallback mode with Catmull-Rom smoothing
- Image import: Files app document picker, large image warnings
- Accessibility: VoiceOver labels, announcements, Dynamic Type support,
  high contrast mask option, Reduce Motion, 44pt touch targets, steppers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 12:36:45 -05:00
00138d944d Fix ImagePipeline operation rendering
Update MaskOperation to store mask dimensions for reconstruction.
Implement proper operation rendering in ImagePipeline:
- Apply mask+inpaint operations with proper mask reconstruction
- Handle adjustment operations by type (brightness/contrast/saturation)
- Scale masks when rendering previews at reduced resolution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:43:53 -05:00
48ee7ecd7c Add Metal-based inpainting and brush selection tools
Implement GPU-accelerated inpainting using Metal compute shaders:
- Add Shaders.metal with dilateMask, gaussianBlur, diffuseInpaint, edgeAwareBlend kernels
- Add PatchMatchInpainter class for exemplar-based inpainting
- Update InpaintEngine to use Metal with Accelerate fallback
- Add BrushCanvasView for manual brush-based mask painting
- Add LineBrushView for wire removal line drawing
- Update CanvasView to integrate brush canvas overlay

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:41:43 -05:00
eec086e727 Add export functionality with format options
- Add ExportView with JPEG, PNG, HEIC format support
- Include quality slider for JPEG compression
- Show image dimensions and estimated file size
- Implement save to Photo Library with proper permissions
- Add share sheet for AirDrop, Messages, etc.
- Wire export button in PhotoEditorView to show ExportView
- Add HEIC encoding extension for UIImage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:30:54 -05:00
daa8ba82bb Integrate services with UI via EditorViewModel
- Add EditorViewModel coordinating masking, contour detection, and inpainting
- Connect PhotoEditorView to viewModel with mask confirmation bar
- Add processing overlay and error toast UI
- Update CanvasView with tap-to-mask functionality
- Add coordinate conversion from view space to image space
- Update ToolbarView to bind to viewModel state
- Wire up undo/redo actions through viewModel

Person, object, and wire removal now flow:
tap -> detect -> preview mask -> confirm -> inpaint

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:29:21 -05:00
20707da268 Implement core project structure and foundation components
Project Setup (Spec 01):
- Configure iOS 17.0 deployment target
- Add photo library usage descriptions
- Create proper folder structure (App, Features, Services, Models, Utilities)

Data Model (Spec 02):
- Add EditOperation enum with mask, inpaint, adjustment cases
- Add MaskOperation, InpaintOperation structs (Codable)
- Add Project model with operation stack and undo/redo support
- Add MaskData with dilation support via vImage

Services (Specs 03-05):
- Add InpaintEngine with Metal + Accelerate fallback
- Add MaskingService wrapping Vision framework
- Add ContourService for wire/line detection and scoring

UI Components (Specs 06-08):
- Add PhotoEditorView with photo picker integration
- Add CanvasView with pinch-to-zoom and pan gestures
- Add ToolbarView with tool selection and inspector panel

Utilities:
- Add ImagePipeline for preview/export rendering
- Add EdgeRefinement for smart brush edge detection
- Add check_build.sh for CI verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:26:37 -05:00
1049057d7d Add Ralph Wiggum agent setup and project specifications
- Add project constitution with vision, principles, and autonomy settings
- Add 15 feature specifications covering full app scope
- Configure agent entry points (AGENTS.md, CLAUDE.md)
- Add build prompt and speckit command for spec creation
- Include comprehensive .gitignore for iOS development

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 23:19:41 -05:00
c64aa4b8ac first commit 2026-01-23 23:17:06 -05:00