What is Viola-Jones algorithm complexity in form like O(log(N))? Even though it's a preety simple algorithm there is no concrete info about it.
-
I don't know how to calculate its complexity, and I'm curious to know the answer. I know that the algorithm is divided into 3 main parts. 1 - Calculating image gradient, 2 - feature extraction, 3 - Classification (Face or No Face). But each of these 3 steps occur in a small ROI inside the image, which is always sliding to the next area and repeat the process. Then the image is re-scaled and the ROI starts again, until the ROI is the same size as the image itself. – Pedro Batista Jan 27 '17 at 11:33
-
I guessed it is O(N) as Viola-Jones clearly has linear complexity, but i'm not sure it will be a correct way to write it – Ilya Katanov Jan 27 '17 at 17:21
-
“there is no concrete info about it” The algorithm is described in detail in the paper it was originally proposed in. Saying there is no information about it is rather strange. – Cris Luengo Dec 18 '21 at 18:28
2 Answers
When we toking about Viola-Jones algorithm complexity we need to remember the steps of this algorithm. According to the original article of Paul Viola and Michael Jones, the algorithm contains 4 main steps:
- Haar Feature Selection
- Creating an Integral Image
- Adaboost Training
- Cascading Classifiers
The complexity of the first step is O(1) because the decision of which Haar Feature to choose is not related to the input.
The complexity of the second step is O(N) because in this step we go over the image matrix. As you know, an Integral Image helps us to perform computations on all the pixels inside that particular feature in O(1) complexity. However, the creation of Integral Image cost O(N) because we go over each pixel in the original matrix and write in the new matrix new value. The value of each point in the new matrix is the sum of all pixels above and to the left, including the target pixel in the old matrix
The complexity of the third step is O(N D^2), where D is the number of features look here why.
The complexity of the fourth step is less than O(N) look here why.
To sum up, as we can calculate from each stage the complexity of the Viola-Jones algorithm is O(n)

- 21
- 3
It's linear (O(N)) in the number (N) of pixels of the input image. All Haar image features are computed in constant time upon the integral image, and computing the latter requires one pass over the input image.

- 11,300
- 2
- 25
- 40