jump to navigation

Efficient coding March 17, 2009

Posted by haryoktav in Taipei.

It was so irritated when my code went so slow. I just added one for-loop and everything walked like Gery (SpongeBob’s pet, it is a snail).

Should I change my Atom N270 to Core7? Yes, it is so tragic that I code VS2005 for image processing on my netbook… lol

But this pages I found just like a warm sunshine on me. It is about make your code more efficient.



        while ((int)p != stopAddress)
            p[0] = (byte)(.299 * p[2] + .587 * p[1] + .114 * p[0]);
            p[1] = p[0];
            p[2] = p[0];
            p += 3;

The code above shows that we can eliminate two for-loop commands to scan x and y of the image..and using the power of pointer.  The type of variable p in the code above is a pointer. Just follow that links.

I am so happy this far but this is just the begining.. eng ing eng..



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: