Re: Faster way?

new topic     » goto parent     » topic index » view thread      » older message » newer message

JDUBE writes:
> I'm wondering if there is a more efficient(meaning faster) way...
>
> for i= 1 to length(image) by 1 do
>     for j=1  to length(image[1]) by 1 do
>         temp=compare(image[i][j],background[1][j]) 
>         if image[i][j]=255 then
>             image[i][j]=background[1][j]
>         end if
>     end for   
> end for

I'm not sure if I understand exactly what you are trying to do here,
but for greater speed you should always try to remove 
calculations from the inner loop. That includes subscripts.

(untested)

for i = 1 to length(image) do
    image_row = image[i]
    back_row = background[i]
    for j = 1 to length(image_row) do
        if image_row[j] != 255 then
            back_row[j] = image_row[j]
        end if
    end for   
    background[i] = back_row
end for

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu