This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
KernelScope is an educational web application for visualizing convolution operations in image processing. Users watch kernels slide across images pixel-by-pixel, inspect individual calculations, and understand how filters like Sobel edge detection work.
Current Status: Specification phase only (see SPEC.md for full requirements)
- Framework: React
- Rendering: Three.js (for efficient pixel rendering and future 3D visualizations)
- Processing: Client-side only, Web Workers for convolution computation
- State: Stateless (no backend, no persistence)
Use Three.js for the image canvas to enable:
- Efficient rendering of images up to 1024×1024 pixels
- Smooth 60fps zoom/pan with pixelated view at high zoom levels
- Foundation for future 3D surface plot visualization
Convolution runs in Web Workers to keep UI responsive during processing.
Two visualization modes to implement:
- Side-by-side: Original and processed images, synced zoom/pan
- Single view (in-place): Wavefront showing processed/original split advancing with raster scan
- Image input (samples + upload, max 1024×1024, auto-convert to grayscale)
- Preset kernels: Sobel (Gx, Gy, magnitude), Gaussian blur, Sharpen
- Custom 3×3 kernel editor
- Edge handling: zero padding, mirror, clamp
- Playback controls: play/pause, speed slider, step buttons, timeline scrubber
- Pixel inspection: click any pixel for detailed calculation breakdown
- Continuous zoom with preset levels, pixelated view when zoomed in
- Color-coded feedback mode (green/red flash for value changes)
- PNG export of processed image
- Use TypeScript for type safety
- One component per file, co-locate related hooks
- Extract reusable logic into custom hooks
- Keep core algorithms (convolution, image processing) separate from UI components
- Offload heavy computation to Web Workers
- Use
useMemo/useCallbackfor expensive calculations - Profile and optimize Three.js render loops
- Avoid re-renders: lift state appropriately, memoize components when needed
- Write unit tests for core algorithms (convolution, edge handling)
- Component tests for interactive behavior
- Test edge cases: small images, large images, extreme kernel values
- Prefer functional components with hooks over class components
- Use descriptive variable names; self-documenting code over excessive comments
- Keep functions small and focused on a single responsibility
- Handle errors gracefully at system boundaries (file upload, image decoding)