UAT 307 Computer Vision and Perception Technology
Worksheet 1 From formula to OpenCV
Objective
Implement edge detection and thresholding from formulas, compare with OpenCV and decide when classical processing is enough; enhance images and evaluate model-based segmentation
Equipment and materials
- Computer with Python, NumPy and OpenCV
- Drone roof images with cloud shadows
- Example code from the module 1 lesson
- A pretrained segmentation model and drone images prepared by the lecturer
Safety
- Computer work only; no flying
Steps
- In class: run Example 1 and compare with cv2.Sobel on the same image
- In class: apply Gaussian blur before edge detection and note the effect on noise
- In class: run Example 2 and compare with cv2.threshold using THRESH_OTSU, then try the cloud-shadow roof image and compare a single threshold with adaptive threshold
- Self-study: apply cv2.createCLAHE and cv2.medianBlur to a hazy or noisy image and compare with Example 3
- Self-study: run a pretrained segmentation model on the lecturer's images, hand-label one image and compute per-class IoU and mIoU as in Example 4
- Self-study: summarise which tasks suit classical image processing and which need AI
Record of results
| Case tested | Result from own code | Result from OpenCV | Difference and reason |
|---|---|---|---|
| Image and method | Value range (min-max) | Roof mean minus ground mean | Pixels more than 20 from clean (%) | What you see in the image |
|---|---|---|---|---|
| Class | True pixels | Predicted pixels | Overlap (intersection) | Union | IoU |
|---|---|---|---|---|---|
Questions
In Table 1, how many extra pixels above a gradient magnitude of 200 did the single noise pixel create, and how did the numbers change after the Gaussian blur? What does blurring cost you?
On the roof image with cloud shadow, where did one threshold for the whole image go wrong? Explain with the shape of the image's histogram, and say why the adaptive threshold fixes it.
From Table 2, which filter removed the black and white specks best while keeping the edge, and why? Why must temperature or reflectance be measured on the original data, not on the enhanced image?
Compare pixel accuracy with the mIoU and per-class IoU in Table 3. If this were a flood survey, which figure should decide whether the model is ready to use?
From your results, give one drone task where classical image processing is enough and one that needs AI, with reasons drawn from what you measured.
Check before you hand in
What to hand in
- Reproducible notebook
- Comparison images of edges and thresholds
- One-page summary of method choice
- Before-and-after enhancement images, and a per-class IoU and mIoU table