UAT 307 Computer Vision and Perception Technology

Worksheet 1 From formula to OpenCV

Analysis activity 3 hAssesses CLO1, CLO2

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

  1. In class: run Example 1 and compare with cv2.Sobel on the same image
  2. In class: apply Gaussian blur before edge detection and note the effect on noise
  3. 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
  4. Self-study: apply cv2.createCLAHE and cv2.medianBlur to a hazy or noisy image and compare with Example 3
  5. 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
  6. Self-study: summarise which tasks suit classical image processing and which need AI

Record of results

Table 1 Own code versus OpenCV for edges and thresholds (steps 1-3)
Case testedResult from own codeResult from OpenCVDifference and reason
Table 2 Image enhancement and noise removal results (step 4)
Image and methodValue range (min-max)Roof mean minus ground meanPixels more than 20 from clean (%)What you see in the image
Table 3 Per-class IoU of the segmentation (step 5)
ClassTrue pixelsPredicted pixelsOverlap (intersection)UnionIoU

Questions

  1. 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?

  2. 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.

  3. 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?

  4. 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?

  5. 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

CLO1 Explain image formation and camera geometry. CLO2 Process images and calibrate cameras. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack