Related Articles

5 users responded in this post

Subscribe to this post comment rss or trackback url
User Gravatar
benryves said in November 10th, 2008 at 6:18 pm

Maybe I’m being an idiot, but if it takes 1 millionth of a second to process one pixel, surely it takes one second to process a one megapixel image and three seconds to process a three megapixel image? That’s definitely linear.

User Gravatar
Maan said in November 10th, 2008 at 9:31 pm

I am honored that you took the time to visit my little blog Ben :). Thank you.

With regards to the math, let me see if I can justify it correctly:
1 Mega pixel = 1024 Kilo pixel = 1048576 pixel. This is our N.
N * N = N^2 = 1099511627776 operation using an O(N^2) algorithm on 1048576 pixel.
With 1 microsecond for each pixel operation, we need 1099511.627776 Second = 18325.193796267 Minute = 305.419896604 Hour = 12.7258 Day.

As for the linearity, Check f(x) = x^2 in this image http://en.wikipedia.org/wiki/Image:Function_ax%5E2.jpg . Without using the image, f(1) = 1, f(2) = 4, f(3) = 9. If the function was linear, there would have been a constant increase in the result of the function as x in f(x) increases. As x increases by 1 each time, the increases in f(x) are 3 then 5.

As I’m still rediscovering the joy of math, please tell me if any of the above seems illogical.

User Gravatar
benryves said in November 11th, 2008 at 4:05 pm

I think that the problem is in the phrasing of the example problem. Saying that it takes 1 millionth of a second to process one pixel implies a pixel-processing algorithm that is O(1), ie constant time. If you then state the size of the image in linear terms (1, 2, 3 megapixel) then you are executing an O(1) algorithm n times, giving you an O(n) algorithm to process the entire image.

If, on the other hand, the algorithm for each pixel sampled the value of every other pixel in the image then that algorithm would be O(n), and running it n times would indeed result in an O(n²) algorithm to process the entire image.

PS 1 megapixel in digital cameras is 1 million pixels, not 1024*1024 pixels. :)

User Gravatar
Maan said in November 14th, 2008 at 2:29 pm

Oh, I see (I thought something was wrong when I started writing that simple math. I thought you were testing me or something :P).
Hmm, yeah, mostly I think he was talking about the 2nd case.
Thanks for a lot the explanation! :)
(Doh! *forehead smack*, 1024 is for bytes only)

User Gravatar
sal said in December 4th, 2008 at 6:45 pm

Okay, this comment has nothing to do with your post!
How come you didn’t link me to your blog!!! it looks great! nice new design :)

Leave A Reply

 Username (Required)

 Email Address (Remains Private)

 Website (Optional)

Bad Behavior has blocked 93 access attempts in the last 7 days.