Homeβ–ΈAI & Machine Learningβ–ΈMedical Scan Classifier (2D): CNN Forward Pass Explained

Medical Scan Classifier (2D): CNN Forward Pass Explained

A flat 2D read on the same CNN forward pass: a fixed blob kernel convolves a synthetic scan, a max-pooled sigmoid outputs a diagnosis probability, and a live ROC curve shows the sensitivity/specificity tradeoff β€” drawn with plain Canvas2D instead of a 3D scene.

AI & Machine Learning2DModerate60 FPSπŸ“± Mobile-adapted⇄ 3D version
2d-medical-diagnosis-ai β†— Open standalone

This 2D companion runs the exact same forward-pass mechanics as the 3D version β€” synthetic scan β†’ fixed blob-detector convolution β†’ max pooling β†’ sigmoid β†’ diagnosis probability β€” but draws every panel with plain Canvas2D rectangles instead of textured planes in a WebGL scene. The input-scan heatmap, the feature-map reveal that tracks the scanning kernel across the grid, and the live ROC curve all read the same way, just flatter and lighter to render. Run single cases against the Normal / Early / Advanced presets to watch the kernel sweep and the probability gauge settle, or fire off a randomized batch to build a confusion matrix and watch the ROC curve and AUC update in real time as you drag the decision threshold.

βš™ Under the hood

A fixed 3Γ—3 blob-detector kernel convolves a synthetic 24Γ—24 scan, the response is global-max-pooled to a single activation, and a sigmoid turns that into a diagnosis probability β€” the same forward-pass pipeline a trained CNN executes at inference, with hand-chosen weights instead of learned ones. A parallel edge-detector kernel is available for the feature-map view but does not feed the score.

convolutional neural networkmedical imagingroc curvesensitivityspecificityconfusion matrixsigmoid

2D Β· HTML5 Canvas 2D Β· 60 FPS target Β· runs fully client-side, no install

Frequently Asked Questions

Why does the threshold slider move sensitivity and specificity in opposite directions?

Lowering the threshold makes the classifier call more cases positive overall, catching more true lesions (higher sensitivity) but also flagging more normal scans as positive (lower specificity). Raising it does the reverse β€” a tradeoff fundamental to any binary classifier with overlapping score distributions.

What does this 2D version change versus the 3D original?

Only the rendering. The convolution kernel, max-pooling, sigmoid scoring, batch generation, confusion matrix and ROC/AUC math are identical β€” this page just paints the three panels with 2D canvas fill/stroke calls instead of textured planes in a Three.js scene, so it loads lighter and needs no WebGL context.

What did you find?

Add reproduction steps (optional)