1. RE: Faster way?

Faster way?

Don't know but you could try this...

Regards,
Mike

integer wsColor
wsColor = 255

image = (image = wsColor) * background + (image != wsColor) * image




dubetyrant at hotmail.com wrote:
> Hello,
> I'm wondering if there is a more efficient(meaning faster) way of
> comparing each element of a sequence with each element of another
> sequence of the same size.Im matching an image with a background 
> image,and
> any whitespace I find,I want to convert to the background image.
> 
> 
> sequence image
> 
> sequence background
> 
> 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
> 
> 
> Note:Sorry I havent been able to help on some of the other problems
> posted here,its just that I really don't have much experience with
> programming.Maybe someday I'll be able to help out more
>                                    Thanks,
>                                       JDUBE
> 
> 



vulcan at win.co.nz

new topic     » topic index » view message » categorize

2. RE: Faster way?

dubetyrant at hotmail.com wrote:
> Hello,
> I'm wondering if there is a more efficient(meaning faster) way of
> comparing each element of a sequence with each element of another
> sequence of the same size.Im matching an image with a background 
> image,and
> any whitespace I find,I want to convert to the background image.
> 
> 
> sequence image
> 
> sequence background
> 
> 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
> 
> 
> Note:Sorry I havent been able to help on some of the other problems
> posted here,its just that I really don't have much experience with
> programming.Maybe someday I'll be able to help out more
>                                    Thanks,
>                                       JDUBE
> 
> 
i have not played with images yet.
i believe an image when read in would be 1 long sequence, right?
no subsequences in it.unless you have read it in that way because of 
memory restrictions. therefor it would not be a 2 dimension table.
you would simply overlay any whitespace found (255) with the image data 
at that same location.
also you are using the 'length' function in your loop control statement. 
each time this statement is executed so would the length function be 
re-calculated.
calculate it once prior to entering the loop would help.

seqsize = length(image)
for i = 1 to seqsize by 1 do
if image[i] = 255 then
image[i] = background[i]
end if
end for

Merry Christmas and Happy New Year to All Euphorians
Rudy
lotterywars

new topic     » goto parent     » topic index » view message » categorize

3. RE: Faster way?

--=======92B10D6=======

At 02:32 25.12.02 +0000, you wrote:

>
>
>dubetyrant at hotmail.com wrote:
> > Hello,
> > I'm wondering if there is a more efficient(meaning faster) way of
> > comparing each element of a sequence with each element of another
> > sequence of the same size.Im matching an image with a background
> > image,and

<snip>

>also you are using the 'length' function in your loop control statement.
>each time this statement is executed so would the length function be
>re-calculated.
>calculate it once prior to entering the loop would help.
>
>seqsize = length(image)
>for i = 1 to seqsize by 1 do
>if image[i] = 255 then
>image[i] = background[i]
>end if
>end for
>
>Merry Christmas and Happy New Year to All Euphorians
>Rudy
>lotterywars

         Actually, this is only true for while loops.  for loops use the 
length() function only once.  Here's a demo:

---------------------------

sequence s

puts(1, "for loop:for i = 1 to length(s) do --accesses length(s) only once\n")
s={1,2,3,4,5}
? s
for i = 1 to length(s) do --accesses length(s) only once
     printf(1, "%2d ", {length(s)})  ? s
     s = s & i
end for

puts(1, "while length(s) > 2 do  --accesses length(s) on each iteration\n")
? s

while length(s) > 2 do  --accesses length(s) on each iteration
     printf(1, "%2d ", {length(s)})  ? s
     s = s[2..length(s)]
end while

         I think Rob commented on this a while back.

                         Bob

--=======92B10D6=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert;
x-avg-checked=avg-ok-1F3D5B31
Content-Disposition: inline


---

--=======92B10D6=======--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu