Images and Image Data

Ken Ray kray at sonsothunder.com
Fri Jul 5 00:00:00 EDT 2002


Michael,

You can try the "repeat for each" construct, which is much faster than
"repeat with". Something like:

on mouseUp
  ## get the data
  put fld "data" into tOrigData
  set the itemdelimiter to TAB

  put 571 into twidth -- data is 571 across
  put 429 into tHeight -- data is 429 lines in height

  ## create the image
  create image
  put it into tID

  set the width of tID to tWidth
  set the height of tID to tHeight

  put empty into iData
  repeat for each line j of tOrigData
    repeat for each item tDataValue of j
      if tDataValue > 0 then  -- above sea level
        put binaryEncode("CCCC",0,0,255,0) after iData ---make green
      else -- point is below sea level
        put binaryEncode("CCCC",0,0,0,255) after iData  --- make blue
      end if
    end repeat
  end repeat
  set the imageData of tID to iData
end mouseUp

See if that is any faster...

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Michael Crawford" <michael.crawford at stonebow.otago.ac.nz>
To: <metacard at lists.runrev.com>
Sent: Thursday, July 04, 2002 9:08 PM
Subject: Re: Images and Image Data


>
>
> Hello,
>
>
> I have modified my script to produce the appropriate image and it works
> perfectly apart from one thing...
>
>
> The script looks like this. Basically it loops across some tab delimited
> data (which is elevation data, that is a height measurement). If that
point
> is above 0, ie above sealevel it makes it green (ie solid land). If it is
0
> or below zero it makes it blue (ie under water)
>
> on mouseUp
>   ## get the data
>   put fld "data" into tOrigData
>   set the itemdelimiter to TAB
>
>   put 571 into twidth -- data is 571 across
>   put 429 into tHeight -- data is 429 lines in height
>
>   ## create the image
>   create image
>   put it into tID
>
>   set the width of tID to tWidth
>   set the height of tID to tHeight
>
>   put empty into iData
>   repeat with j = 1 to tHeight
>     repeat with i = 1 to tWidth
>       put item i of line j of tOrigData into tDataValue
>       if tDataValue > 0 then  -- above sea level
>         put binaryEncode("CCCC",0,0,255,0) after iData ---make green
>       else -- point is below sea level
>         put binaryEncode("CCCC",0,0,0,255) after iData  --- make blue
>       end if
>     end repeat
>   end repeat
>   set the imageData of tID to iData
> end mouseUp
>
>
> The only problem is the speed of execution. It is painfully slow. A bit of
> checking reveals that it is the line:
>
> put item i of line j of tOrigData into tDataValue
>
>
> that is causing the bottleneck. There must be a better way to do this? In
> the past I have never really bothered optimising these sort of repeat
loops
> as it has always been fast enough for me. With 571 x 429 data points
though
> it is just too slow. Does any one have any suggestions?
>
>
> Thanks
>
>
> Michael Crawford
>
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list