🐛 Detector de Plagas en Cultivos — Clasificador de Características de Textura en Vivo
Observa un clasificador real de características de textura (varianza local/densidad de bordes) escanear una cuadrícula de imagen de hoja simulada parche por parche, marcando en vivo las regiones dañadas por plagas mediante una votación k-NN frente a parches de referencia sanos/dañados.
Acerca de esta simulación
This simulation builds a genuine, if compact, computer-vision pipeline from scratch. A procedural synthetic leaf image is generated pixel by pixel, complete with jagged pest-damage blotches whose local statistics genuinely differ from healthy tissue. A scanning window then sweeps the leaf patch by patch, and for every patch three real texture features are computed straight from the pixel buffer: mean intensity, local variance, and Sobel-based edge density. Each patch is classified healthy or damaged by a real k-nearest-neighbours vote against a labelled reference set, with the decision visualised live in feature space.
🔬 Qué muestra
A CanvasTexture-rendered leaf with a scanning window sweeping across a 12×12 patch grid. Each patch's mean intensity, population variance and Sobel edge-density are computed from real pixel data, normalised, and compared by Euclidean distance to a labelled reference set of healthy/damaged exemplars sampled from the same leaf. The feature-space scatter panel plots every reference patch plus the current patch and draws lines to its k nearest neighbours.
🎮 Cómo usarlo
Adjust k (1–11) to change how many neighbours vote, and the damage-vote-threshold (0.1–0.9) to change how many of those neighbours must say "damaged" before the patch is flagged. Scan speed controls how fast the window sweeps. Regenerate leaf resamples a fresh synthetic leaf with new damage blotches and rebuilds the reference set; Pause/Resume freezes the scan for inspection.
💡 ¿Sabías qué?
Sobel edge detection, invented in the early 1970s, is still one of the most widely used edge operators because its two small 3×3 kernels approximate the image gradient cheaply enough to run in real time — exactly what lets this simulation recompute genuine edge density for every patch, every frame, without ever pre-baking the answer.
Preguntas frecuentes
What real features does the classifier compute from each patch?
For every scanned patch the simulation reads the actual pixel data of the synthetic leaf image and computes three genuine texture statistics: the mean grayscale intensity, the population variance of intensities within the patch (a measure of local roughness), and an edge density obtained by running real Sobel Gx/Gy convolution kernels over every interior pixel and counting how many exceed a gradient-magnitude threshold. None of these numbers are faked or looked up — they are derived directly from the RGBA buffer that also drives what you see on screen.
How does the k-nearest-neighbours classifier actually decide healthy vs. damaged?
A reference set of patches is sampled from the same leaf and labelled using ground-truth pest-blotch coverage (only used to build this labelled set, never given to the classifier for unknown patches). Each reference patch's three features are z-score normalised. When a new patch is scanned, its features are normalised the same way, the real Euclidean distance to every reference patch is computed, the k closest are kept, and the patch is flagged damaged if the fraction of damaged neighbours among those k meets the damage-vote-threshold slider — otherwise it is healthy.
Why does pest damage raise local variance and edge density?
Necrotic or chewed leaf tissue tends to have irregular, high-contrast mottling rather than the smooth mottled green of healthy tissue, so the pixel-intensity variance within a damaged patch is higher. The ragged boundary between damaged and healthy tissue also produces far more sharp intensity transitions, which is exactly what a Sobel filter is designed to detect, so edge density spikes near and inside damage.
What do the k value and damage-vote-threshold controls change?
k sets how many nearest reference patches are consulted for each vote — a small k reacts fast to local texture but is noisier, a large k smooths the decision but can blur small damage spots. The damage-vote-threshold sets what fraction of those k neighbours must be labelled damaged before the patch itself is flagged damaged; lowering it makes the detector more sensitive (more false positives), raising it makes it stricter (more missed damage).
Is this a real classifier or just a colour threshold in disguise?
It is a real, if simplified, machine-learning pipeline: genuine feature extraction (variance, Sobel edge density, mean intensity) from real pixel data, a genuine labelled reference set, real Euclidean distance computation, and a real majority-vote k-NN decision rule. It intentionally omits things like data augmentation or a learned metric, but every number driving the classification is computed live from the image, not hand-tagged per patch.
A real texture-feature (local variance/edge-density) classifier scans a simulated leaf-image grid patch by patch, flagging pest-damage regions live as a k-NN vote against healthy/damaged reference patches.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install