DEV Community

Joy
Joy

Posted on

What I Learned in My First Computer Vision Class: How a Computer Sees

This week I learned about computer vision. I knew nothing about it before. In this post I share what I learned in simple words. I hope it helps other beginners too.

A computer does not see a picture. It sees numbers.

When I look at a photo, I know what it is in one second. A computer cannot do this. It only sees numbers.

A photo is made of small squares called pixels. Each pixel has three numbers: red, green and blue. Each number goes from 0 (none) to 255 (full). So a photo with 400 rows and 600 columns has 400 × 600 × 3 = 720,000 numbers.

In the notebook, I looked at one pixel from the photo. It was [106, 99, 91]. The three numbers are close to each other and not very high, so the colour is a dark grey. Another pixel was [4, 16, 40]. The numbers are very small, so it is almost black.

Filters help the computer find edges

An edge is a place where dark suddenly changes to bright, like the side of a bus.

To find edges, we use a filter. A filter is a small grid of numbers called weights. You put it on top of the pixels, multiply each pixel by its weight, and add all the results. For example, the Sobel filter is:

-1  0  1
-2  0  2
-1  0  1
Enter fullscreen mode Exit fullscreen mode

It does "right side minus left side". If both sides are the same, the answer is 0, so there is no edge. If the left side is dark and the right side is bright, the answer is big, so there is an edge.

I also tried a blur filter. It has 25 weights of 0.04, so it takes the average of 25 pixels and makes the photo soft.

blur = np.ones((5, 5)) / 25
sobel_x = np.array([[-1, 0, 1],
                    [-2, 0, 2],
                    [-1, 0, 1]])
Enter fullscreen mode Exit fullscreen mode

CNN: the computer learns its own filters

A CNN (Convolutional Neural Network) does not use filters that a person writes. It starts with random weights, makes a guess, and checks the right answer. Then it changes the weights a little. After thousands of photos, it finds good filters by itself.

Three main tasks

  • Classification: one name for the whole photo
  • Detection: a box around each object
  • Segmentation: a label for every pixel

I tried all three with a small YOLO model.

Classification. On a sample photo of two men, the model said "suit" with only 34.7%. It cannot say "two people", because it can only choose from 1,000 names.

Detection. On a bus photo, the model found 1 bus and 4 people. There is a setting called conf, the confidence threshold. With conf=0.9 I got only the bus. The people disappeared, because the model was less than 90% sure about them. With a low threshold I get more boxes, but some can be wrong. This is the same problem as in medical screening: too many false alarms, or too many missed cases.

Segmentation. The model made a mask for every object. I counted the pixels: the bus had 92,230 pixels, and the stop sign only 644. Segmentation can tell me how much of the photo each object covers.

Testing with my own photos

This was my favourite part. I tested two photos from the internet.

A miss: ibiraha. Ibiraha is a street food in Rwanda. The model said "pineapple" [91.9%]. The food is golden and has many pointy corners, so the model thought it looked like a pineapple. The model has never seen ibiraha, and it cannot say "I don't know". It must choose one of its 1,000 names.

A hit: a street in Kigali. In this photo there are motorbikes, cars and people in daylight. The detector found [person,motorcycle, car]. These are things the model saw many times in training.

When models fail

A model only knows what it was trained on. To test this, I made my Kigali street photo harder in four ways. Then I ran the detector on each version.

Version Objects found People found
Original 8 4
Very dark 5 3
Upside down 0 0
Low resolution 0 0
Blurry 0 0

What I saw:

  • The original photo gave 8 objects and 4 people. This is a good result.
  • In the dark photo, the model lost some objects, but it still found most of them.
  • The upside down, low resolution and blurry photos gave 0 objects. The model found nothing.

Why? Upside down photos have the same pixels, but the model never saw streets in this position in training. In the low resolution and blurry photos, the edges and small details are gone, and the model needs them to recognise cars and people.

This is a real problem. Cheap phone cameras, dusty lenses and bad light are common in many places in Africa. A model trained only on clear photos can fail there.

What I learned

  1. A computer sees only numbers. A filter helps to find patterns in them.
  2. A model only knows what it was trained on.
  3. A high confidence does not mean the answer is correct.
  4. Local data matters. A model trained on photos from other countries can fail on our food, roads and crops.

This is why computer vision for Africa needs African data. For my next step, I want to collect about 100 photos of Rwandan food and train a small model that knows ibiraha.

Thank you for reading!

Top comments (2)

Collapse
 
grace_umutoniwase_b6e978d profile image
Grace UMUTONIWASE •

This is a very interesting and informative blog! 👏❤️ I love how you explained Computer Vision in simple words and shared practical experiments to show how AI models recognize images. Your example of ibiraha being classified as a pineapple was especially interesting, and your point about the importance of African data is very powerful.

One thing I think could make this blog even stronger is explaining a little more about how you tested the model and whether the results might change with different images or model settings. For example, getting zero detections from blurry or low-resolution images is interesting, but testing different levels of blur or image quality could help us understand exactly where the model starts to fail. Also, collecting 100 photos of ibiraha is a great start, although more diverse images may be needed to train a model that recognizes it reliably.

Overall, great work! I appreciate your honesty about the limitations of AI and how you connected your learning to real challenges in Africa. I look forward to seeing what you build next! ❤️👏

Collapse
 
uwimana_xaverine_44456038 profile image
uwimana Xaverine •

This is a fantastic and very clear breakdown of computer vision!

I really love how you explained complex technical concepts like pixels, filters, and CNN weights using simple, everyday language. Your practical tests especially discovering how a model misidentified ibiraha as a pineapple because it has never seen local Rwandan food before make a brilliant point about why local data matters.

It is a great reminder for beginners that AI is only as smart as the data it trains on. Great work!