الرئيسية / خدماتنا / الذكاء الاصطناعي
Computer VisionCNNClassificationNeural Network

Image Classifier (CNN-style)

A complete image classification pipeline — from raw pixels to feature vectors through a 3-layer neural network. Classifies images into Cat / Dog / Car / Tree.

معاينة مباشرة — تفاعلية

Image Classifier (CNN-style)

Feature extraction + MLP neural network — classifies into Cat / Dog / Car / Tree

Input (200×200)
Prediction
Click "Classify" to see prediction
How does it work?
  1. Resize: Image is downsampled to 32×32 pixels (standard input size).
  2. Features: 24 numerical features are extracted: color means/stds, Sobel edge strength, texture variance, spatial distribution, and shape symmetry.
  3. Neural Network: The 24-D vector passes through a 3-layer MLP (24→16→8→4) with ReLU activations.
  4. Softmax: Outputs 4 probabilities that sum to 100%. The highest is the prediction.

How This Project Was Built

Step-by-step explanation of the methodology and algorithms used

01

Image Preprocessing (Resize & Grayscale)

Every uploaded image is downsampled to a fixed 32×32 pixels using bilinear interpolation. The 32×32 size is the standard input for many classic CV pipelines — small enough for fast inference, large enough to preserve structure.

canvas → drawImage(img, 0, 0, 32, 32)
02

Feature Extraction — Color (9-D)

Compute per-channel mean and standard deviation for R, G, B plus brightness, saturation, and the dominant color channel. These features distinguish warm (Cat/Dog) from cool (Car) and green-dominant (Tree) images.

μR = ΣR / N, σR = √(Σ(R-μR)² / N)
03

Feature Extraction — Edges (4-D)

Apply Sobel kernels horizontally and vertically to the grayscale image, plus two diagonal kernels. The result is edge strength in 4 directions. Cars have strong horizontal edges; trees have strong vertical edges.

Gx = Sobel_h * Gray, Gy = abs(Sobel_v * Gray)
04

Feature Extraction — Texture (4-D)

Compute local variance, contrast, and Shannon entropy across 3×3 neighborhoods. Smooth regions (sky) have low entropy; detailed fur has high entropy.

H = -Σ p(i) · log2(p(i))
05

Feature Extraction — Spatial & Shape (7-D)

Compare center vs edges, top vs bottom, and compute horizontal & vertical symmetry. Aspect ratio captures object proportions.

SymH = 1 - Σ|gray(x,y) - gray(x, W-1-y)| / N / 255
06

Neural Network — MLP with 24-D Feature Matrix

A 3-layer MLP: Input(24) → Dense(16, ReLU) → Dense(8, ReLU) → Dense(4, Softmax). Each layer applies learned weights, a bias, and an activation. Total of 560 parameters.

h1 = ReLU(W1 · x + b1) h2 = ReLU(W2 · h1 + b2) y = Softmax(W3 · h2 + b3)
07

Pre-training on Synthetic Data

To get realistic weights, we generated 32 synthetic images (8 per class) using procedural shapes — colored blobs for cats, rectangles for cars, etc. The network learns to distinguish these patterns during a one-time offline training pass, and weights are shipped with the model.

08

Softmax & Classification

The 4 logits are passed through softmax to produce probabilities summing to 1. The argmax is the predicted class. We display all 4 probabilities as a bar chart so users can see how confident the model is.

P(class_i) = exp(logit_i) / Σ exp(logit_j)

التقنيات المستخدمة

Computer VisionSobel edges, color stats, texture
Neural Network3-layer MLP from scratch
ReactuseState, useRef, useEffect
Canvas APIImage manipulation & extraction
Feature Engineering24 hand-crafted features
SoftmaxMulti-class probability output