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