Thank-you guys so much... this works great now.
w1=w-1
h1=h-1
for k=1 to 217
surf1=cor(k).rgBSurface
surf2=cor2(k).rgbSurface
if k mod 10=0 then
progressBar1.value=k
progressBar1.refresh
end
if c2done(k)=false then
if stopthread=true then exit
for j=0 to h1
for i=0 to w1 step 8
t1=surf1.pixel(i,j)
t2=surf1.pixel(i+1,j)
t3=surf1.pixel(i+2,j)
t4=surf1.pixel(i+3,j)
t5=surf1.pixel(i+4,j)
t6=surf1.pixel(i+5,j)
t7=surf1.pixel(i+6,j)
t8=surf1.pixel(i+7,j)
q1=t1.red
q2=t2.red
q3=t3.red
q4=t4.red
q5=t5.red
q6=t6.red
q7=t7.red
q8=t8.red
if t1=c1 then surf2.pixel(i,j)=&c00FF00 else
surf2.pixel(i,j)=rgb(q1,q1,q1)
if t2=c1 then surf2.pixel(i+1,j)=&c00FF00 else
surf2.pixel(i+1,j)=rgb(q2,q2,q2)
if t3=c1 then surf2.pixel(i+2,j)=&c00FF00 else
surf2.pixel(i+2,j)=rgb(q3,q3,q3)
if t4=c1 then surf2.pixel(i+3,j)=&c00FF00 else
surf2.pixel(i+3,j)=rgb(q4,q4,q4)
if t5=c1 then surf2.pixel(i+4,j)=&c00FF00 else
surf2.pixel(i+4,j)=rgb(q5,q5,q5)
if t6=c1 then surf2.pixel(i+5,j)=&c00FF00 else
surf2.pixel(i+5,j)=rgb(q6,q6,q6)
if t7=c1 then surf2.pixel(i+6,j)=&c00FF00 else
surf2.pixel(i+6,j)=rgb(q7,q7,q7)
if t8=c1 then surf2.pixel(i+7,j)=&c00FF00 else
surf2.pixel(i+7,j)=rgb(q8,q8,q8)
next
next
c2done(k)=true
end
next
----------
Jeffrey J. Borckardt, Ph.D.
Department of Psychiatry and Behavioral Sciences
Medical University of South Carolina
67 President Street
IOP, 5 South BA 504 E
Charleston, SC 29425
(843)792-3295
borckard at musc dot edu
On Jan 28, 2005, at 4:06 PM, Joseph J. Strout wrote:
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>
_______________________________________________
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>
|