Im trying to find computation complexity for a algorithm with respect to number of pixels, what procedure i need to follow. The algorithm is based on image registration.
Asked
Active
Viewed 630 times
0
-
Please provide the algorithm in question. Then we can at least know what you're asking. – Joris Schellekens Apr 01 '19 at 14:04
-
Algorithm is dynamic programming to match the feature points similarity value. and for ransac algorithm with SIFT. – krishna Apr 02 '19 at 16:18
-
Again, this is not very specific. Edit your question to list the exact (minimal) code that is being run. – Joris Schellekens Apr 03 '19 at 07:36
1 Answers
1
As a rough measure, you can look at the number of loops, or the number of times each pixel is viewed/edited by the algorithm.
e.g. this algorithm converts an image to sepia colors
BufferedImage img = <input of the algorithm>
for(int i=0;i<img.getWidth();i++){
for(int j=0;j<img.getHeight();j++){
Color c = new Color(img.getRGB(i,j));
double r = c.getRed();
double g = c.getGreen();
double b = c.getBlue();
double r2 = 0.39 * r + 0.76 * g + 0.19 * b;
double g2 = 0.34 * r + 0.69 * g + 0.17 * b;
double b2 = 0.27 * r + 0.53 * g + 0.13 * b;
}
}
I can see there are two loops, one that iterates over the width of the image, one that iterates over the height of the image.
Each pixel is visited once by this algorithm. Its complexity is O(n) with n being the number of pixels in the input image.

Joris Schellekens
- 8,483
- 2
- 23
- 54