DEV Community

Inezayimana Henriette
Inezayimana Henriette

Posted on

computer vision

i learn how machines learn to see: a beginners guide to computer version
so from pixels to predictions, and why its matters for africa
show your patterner a photo of a dog have duck on the head and he/she tell you what it is in a split second. they ever suggest if it is cute puppy.show the same photo to a computer and it sees something very different: a hugr grid of numbers.
computer vision is the field of al that teaches a computers to turn those numbers into a meaning. in this post i walk through how it works, from a single pixel to models that can find buildings from space, using the experiments i ran in hands on notebook
what computer vision ?
for me is to the computers get a meaning from images and video.
almost every vision system answer one or more of three qwestion : what is any image if itis cat,a cassavaleaf,a bus.
where it it? which pixels, which part of the picture
what happening? person crossing the road, a crowd forming( especially in video)
how computer sees a numbers: a digital image is a grid of tiny sqweres called pixels.
where each pixel holds three numbers: how much red,green,and blue it contains,each from 0 to 255. so a small 400*600*3=720,000 numbers. a modern phone photo has more than 30 million. the computer never see "a dog". it only sees these numbers of a computer verision mis going from numbers to meaning.
why 255? each value is stored in 8 bits, and 8 bits can hold 2 in 8 bits =255 different values, from 0 to 255. zero means none of that colour and 255 means full strength
my work i tested the photo of a dog in a babble bath, weearing glasses with a yellow robber duck on its head. i asked python to find the 10*10 patch of pixel with the most contrast, and it landed on the duck. one pixel there is full red, full green and almost no blue, and red plus green at full strength is exactly yellow .
the computer had no idea it looking at a duck ,only at a very yellow set of numbers. a color image is rearly three grid stacked together one each for red, green and blue. in the duck blue grid the values are tiny becouse a yellow object contains almost no blue .
how a computer find edges once you maths on them .
the most important operation in computer vision is the filter. a small grid of weights that slides over the images. at each position you multiply the pixels under filter by its weights and add everything up.
a famous example is the solber filter:

-1 0 1
-2 0 2
-1 0 1
it subtracts the left side
from the right side . look at what happens on two small patches:
. a flat patch where every pixel is 1000: the left side gives -400, the right side gives +400 and the total is 0 . no edge.
.an edge patch where the left is 0 and the right is 200: and the right is 200: the left give 0, the rigt gives +800, and the total is 800. a bright gives edge.
so the filter light up exactly where brightness change sharply, whaich is what an edge is. flip the filter on its side and it finds horizontal edges instead. other filters blur or sharpen an image. the only difference between them is the numbers inside.
From hand-made filters to CNNs

Someone designed the Sobel filter by hand. A convolutional neural network (CNN) does the same sliding-and-adding, but nobody designs the filters. The network learns them from labelled examples using the same training loop as any other neural network.

Researchers who look inside trained CNNs find a neat pattern: the first layers learn edges and colours, the middle layers learn textures and parts such as eyes or wheels, and the last layers respond to whole objects.

Pixels, then edges, then textures, then objects.

Five core tasks
Classification: one label for the whole image.
Detection: a box around each object.
Segmentation: a label for every single pixel.
OCR: reading text in images.
Tracking: following objects across video frames.

In my notebook I ran three of these on the same street photo using small pretrained YOLO models. The classifier gave one label, “minibus”, at 57% confidence. That is not wrong, but it is not very useful for a busy street. The detector found the bus and four people with boxes. The segmenter outlined exactly which pixels belonged to each object. More detailed output needs more detailed training labels, and those cost more to create.

YOLO stands for You Only Look Once. Older detectors first proposed possible regions and then classified each one, which was accurate but slow. YOLO looks at the whole image in a single pass, which is fast enough for live video and small devices.

Why is computer vision booming now?

Five things came together:

Cameras everywhere. Every phone is a camera and a small computer.
Data. Huge image collections and satellite imagery.
Compute. Cloud GPUs for training, and small models that run on phones.
Pretrained models. You do not start from zero. You can adapt an existing model with a few thousand local photos.
Multimodal AI. Assistants can now read images as well as text. A Vision Transformer even cuts an image into 16 × 16 patches and treats each patch like a word.
Computer vision across Africa

This is the part that excites me most. Some examples from the course material:

Agriculture: Nuru helps farmers diagnose cassava diseases from a leaf photo, offline, on a basic phone.
Health: In Nigeria, software scored chest X-rays to decide who should get a lab test for tuberculosis. In one project covering 5,298 people, 85 TB cases were found.
Conservation: In Gabon, smart camera traps spot elephants and people and alert rangers by satellite within minutes.
Finance: Smile ID matches a selfie to an ID photo and checks that it is a real, live person.
Mapping: Google’s Open Buildings dataset outlines about 1.8 billion buildings, helping with vaccination planning and disaster response.
Accessibility: BLAIVA, built by FabLab Rwanda and still in beta, is a wearable camera that describes objects, text and faces through earphones.

That last one was built in Kigali. It is a reminder that the people reading this can build these systems too.

When models fail

A model only knows what it was trained on. To see this, I made the street photo harder in three ways: very dark, upside down and very low resolution. These are everyday conditions with cheap phones, poor lighting or a dusty lens. The detector’s results changed in each case. In one it even invented an object that was not there.

This matters because most popular models were trained mostly on photos from Europe, North America and Asia. They can struggle with African crops, clothing, road scenes, skin tones and lighting. For a face-verification system, a missed match is an inconvenience. For a medical screening tool, a wrong answer could harm someone. The fix is local data and fine-tuning, and being honest about how a model was test
Try it yourself

You only need a free Google Colab account:

Load a photo with Python and print its shape. Notice that it is height × width × 3.
Print the red, green and blue values of one pixel.
Pick the 10 × 10 patch with the most contrast and look at its numbers.
Run a Sobel filter and watch the edges appear.
Run a pretrained YOLO model on your own photos, and keep one hit and one miss.

Try a photo of your street, a market or a plant leaf. Where does the model succeed, and where does it fail?

Final thoughts

Computer vision looks like magic until you see what is inside: images are numbers, filters find patterns in those numbers, and networks learn which patterns matter. Once you understand that chain, you can start building tools that solve problems close to home, from crop disease to accessibility.

The next time you glance at a photo and instantly know what it shows, remember that a computer needs millions of numbers and a lot of training to do the same.

Top comments (1)

Collapse
 
ineza250 profile image
Inezayimana Henriette •

computer version