At 3:32 PM -0500 1/28/05, Jeff Borckardt wrote:
I have a program that takes several full-color images
By "several" you mean 217, right? Or do I misunderstand?
and wherever each image displays a predetermined color (for example
blue), the program turns it green and coverts all other sections of
the picture to greyscale.
And by convert to greyscale, you mean copy the red channel into the
blue and green channels? (Normally I would expect some sort of
mixing of the three channels.)
This takes a long time... is there a faster way?
Yes, there are a lot of things you can do to speed this up. The
chief one is, and this is a general principle whenever speed matters:
Move anything that can be moved out of the loop, out of the loop.
For example, your loop contains several lines like this:
cor2(k).rgbsurface.pixel(i,j)=rgb(0,255,0) //green
This should instead read:
surf2.Pixel(i,j) = &c00FF00
where "surf2" is a local variable of type RGBSurface, to which you
have assigned cor2(k) right at the top of the k loop. No need to
look up cor2(k) on every pixel, and most importantly, no need to get
and destroy the RGBSurface object on every pixel. (Actually your
current code creates and destroys three of them on each pixel!)
That will make a big difference, especially if you aggressively apply
this general principle.
Best,
- Joe
--
REAL World 2005 - The REALbasic User Conference
March 23-25, 2005, Austin, Texas
<http://www.realsoftware.com/realworld>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>
|