Images and Image Data
Michael Crawford
michael.crawford at stonebow.otago.ac.nz
Thu Jul 4 22:11:01 EDT 2002
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
More information about the metacard
mailing list