import React, { useEffect, useState } from 'react'; import PanelContainer from '../ui/PanelContainer'; import GlowingBox from '../ui/GlowingBox'; import FeatureMap from '../ui/FeatureMap'; import { ScanSearch, MoveRight } from 'lucide-react'; const ConvolutionPanel: React.FC = () => { const [kernelPosition, setKernelPosition] = useState({ x: 0, y: 0 }); const [isAnimating, setIsAnimating] = useState(true); // Simple edge detection kernel const kernel = [ [-1, -1, -1], [-1, 8, -1], [-1, -1, -1] ]; // Animation for sliding kernel useEffect(() => { if (!isAnimating) return; const maxPos = 5; // 8x8 input - 3x3 kernel + 1 const interval = setInterval(() => { setKernelPosition(prev => { const newX = prev.x + 1 > maxPos ? 0 : prev.x + 1; const newY = newX === 0 ? (prev.y + 1 > maxPos ? 0 : prev.y + 1) : prev.y; return { x: newX, y: newY }; }); }, 800); return () => clearInterval(interval); }, [isAnimating]); return (

Kernel Sliding

{/* Input image with overlay */}
{Array(64).fill(0).map((_, index) => { const x = index % 8; const y = Math.floor(index / 8); // Determine if cell is within the current kernel position const isInKernel = x >= kernelPosition.x && x < kernelPosition.x + 3 && y >= kernelPosition.y && y < kernelPosition.y + 3; return (
); })}
{/* Animated kernel */}

Kernel/Filter

{kernel.flat().map((value, i) => (
{value}
))}

Edge detection filter

Feature Map

Resulting feature map from convolution operation

); }; export default ConvolutionPanel;