Foundations to Frontier
Tests
E. Deep Learning › E9 Object Detection Architectures

Sliding Window and Selective Search

Before deep detectors, finding objects meant classifying a huge number of windows. Sliding-window detectors (Viola–Jones for faces, HOG with an SVM for pedestrians) slide a fixed-size window over an image pyramid, which is accurate but expensive and tied to one aspect ratio. Selective search (Uijlings et al., 2013) instead groups an over-segmentation bottom-up, proposing about 2,000 boxes that cover nearly all objects, the proposals R-CNN classified. This page covers window counts, image pyramids, IoU, and hierarchical grouping. In the exercises you compute IoU and window counts, then compare the two on synthetic scenes: selective search covered 92% of objects with about 62 proposals per image, while the sliding window needed 2,018 to cover all of them.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Where should we look?

A classifier says what is in a picture. A detector must also say where. The obvious method is to slide a small window everywhere, at every size, and ask the classifier about each window, but that is many thousands of questions per image. A smarter method is to guess where objects might be first: group pixels that look alike into regions, merge neighbouring regions step by step, and propose the boxes around them. Only those few thousand proposals are classified.

Detection lab
windows to classify: 8,549 (each scale shrinks the image by 1.5×). Region proposals and convolutional sharing replaced this brute force.
Why engineers care

Every detector on a robot, car or satellite must decide where to look. The trade-off between exhaustive search and smart proposals, and the IoU measure of a good box, underlie every detector in this section.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A sliding-window detector classifies…
  2. 2. Selective search proposes boxes by…
  3. 3. Proposals mainly save…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • IoU: area of intersection / area of union. Two 10 × 10 boxes offset by 5 in x and y overlap in 25, so IoU = 25/(100 + 100 − 25) = 25/175 ≈ 0.143. A detection usually counts as correct at IoU ≥ 0.5.
  • Window count: an n × n image, a w × w window and stride s give ((n − w)/s + 1)² windows. For 640, 64 and 8 that is 73² = 5,329.
  • Image pyramid: to find objects of other sizes, shrink the image by a factor (1.5 here) and repeat. Six levels give 8,558 windows for a single window shape; each extra aspect ratio multiplies that again.
  • Hierarchical grouping:
    • start from n regions;
    • merge the most similar adjacent pair n − 1 times;
    • every region ever formed is a proposal, 2n − 1 in total.
📝 Quick check (Level 1)
0/3 answered
  1. 1. IoU of identical boxes:
  2. 2. Windows for n = 64, w = 16, s = 4:
  3. 3. Proposals from grouping 32 initial regions:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Proposals in code

Exercise 1.

  • IoU matched the hand calculations, including 0 for touching boxes.
  • A single 64 × 64 window at stride 8 over 640 × 640 needed 5,329 evaluations; with six pyramid levels, 8,558.

Practice.

  • OpenCV provides selective search: cv2.ximgproc.segmentation.createSelectiveSearchSegmentation(), in fast or quality mode.
  • Selective search’s diversity:
    • several colour spaces;
    • several similarity measures (colour, texture, size, fill);
    • initial segmentations at several scales (Felzenszwalb–Huttenlocher graph segmentation).
  • Alternatives: EdgeBoxes scores windows by enclosed contours. Learned region proposal networks (Faster R-CNN, E9-4) replaced hand-made proposals.
  • Cost: selective search takes a few seconds per image on a CPU, which became R-CNN’s bottleneck once the CNN was shared.
ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
ss.setBaseImage(img); ss.switchToSelectiveSearchFast(); boxes = ss.process()   # about 2,000 (x, y, w, h)
🐍 Exercise 1: IoU and window counts
Implement IoU, sliding-window and pyramid window counts, and the best IoU among proposals.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Selective search's initial regions come from…
  2. 2. Fast-mode selective search proposes about…
  3. 3. What replaced hand-made proposals?

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Sliding windows.

  • Viola and Jones (2001) made sliding windows real-time for faces. Integral images give constant-time box sums, and a cascade of boosted classifiers rejects most windows after a few cheap tests.
  • Dalal and Triggs (2005) used histograms of oriented gradients (HOG) with a linear SVM for pedestrians.
  • Deformable part models (Felzenszwalb et al., 2010) added parts on springs.

The cost grows with positions × scales × aspect ratios, which limits the classifier’s complexity.

Objectness and proposals. Objects are usually spatially coherent regions with closed boundaries. Grouping exploits this: a region that merges into a coherent whole at some level of the hierarchy is a candidate object, at whatever size or shape. Selective search covered about 98% of PASCAL VOC objects at IoU 0.5 with about 2,000 proposals per image (fast mode), class-independently, which made it possible to apply an expensive CNN to each proposal (R-CNN, E9-2).

Limits.

  • Proposals are fixed before classification, so missed objects can never be detected.
  • Hand-designed similarities fail for camouflaged or touching objects.
  • The step is slow on a CPU.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Viola–Jones's speed came from…
  2. 2. Selective search recall at IoU 0.5 on VOC (fast mode):
  3. 3. A missed proposal…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How much search do proposals save?

History.

  • P. Viola and M. Jones (2001) introduced real-time face detection with boosted cascades.
  • N. Dalal and B. Triggs (2005) introduced HOG features for pedestrian detection.
  • P. Felzenszwalb and D. Huttenlocher (2004) introduced efficient graph-based segmentation.
  • J. Uijlings, K. van de Sande, T. Gevers and A. Smeulders (2013) introduced selective search.
  • C. L. Zitnick and P. Dollár (2014) introduced EdgeBoxes.

Exercise 2. The data are 16 synthetic 64 × 64 scenes, each with 3 two-tone rectangular objects on a noisy background. Two methods are compared:

  • Sliding window: windows of 5 sizes × 3 aspect ratios at stride 4.
  • Simplified selective search:
    • initial regions from a smoothed, brightness-quantised image (connected components);
    • repeated merging of the most similar adjacent pair;
    • every region’s box is a proposal.

The measure is recall: the share of objects with some box at IoU ≥ 0.5 or ≥ 0.7.

method windows per image recall at IoU 0.5 recall at IoU 0.7
selective search 61.5 0.917 0.812
sliding windows 2,018 1.000 0.896
  • Proposals cut the search 33-fold while still covering 92% of objects. That is the trade R-CNN relied on.
  • They also miss objects. All four missed objects touched or overlapped another object, though most touching objects were still found. A second set of scenes (seed 1) gave 54 proposals and 85% recall.
  • A first attempt that started from a 4-pixel grid instead of a boundary-following segmentation reached only 79% recall with 511 proposals. Snapping boxes to a grid ruins the IoU of small objects, which is why selective search starts from a segmentation.
🐍 Exercise 2 (research): how much search do proposals save?
Compare a sliding-window detector with a simplified selective search on synthetic scenes: windows per image and recall.

Proposals in AI, robotics and aerospace

  • Embedded detection: cascades in the Viola–Jones style still run on low-power cameras for face and object detection.
  • Remote sensing: class-agnostic proposals help find unusual objects in satellite images before classification.
  • Robot grasping: segmentation-based proposals locate graspable objects on cluttered tables.

References

  1. P. Viola, M. Jones (2001). “Rapid object detection using a boosted cascade of simple features.” Proc. CVPR.
  2. N. Dalal, B. Triggs (2005). “Histograms of oriented gradients for human detection.” Proc. CVPR.
  3. J. R. R. Uijlings, K. E. A. van de Sande, T. Gevers, A. W. M. Smeulders (2013). “Selective search for object recognition.” IJCV 104(2).
  4. P. F. Felzenszwalb, D. P. Huttenlocher (2004). “Efficient graph-based image segmentation.” IJCV 59(2).
  5. C. L. Zitnick, P. Dollár (2014). “Edge boxes: locating object proposals from edges.” Proc. ECCV.