sec : U Re: Writing to a specific line of a BIP or BIL file? [message #33411] |
Thu, 19 December 2002 18:10 |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
Jonathan Greenberg wrote:
>
> (thanks Andrew for your answer to my ASCII file question)
>
> I now want to know, using IDL and/or ENVI function, how do I write data to a
> specific LINE of a BIP or BIL file? Its easy to read it (envi_get_slice),
> but not easy to write that slice. The brute force is to load the entire
> image into memory, assign that specific line the new values, and then
> rewrite the entire image back to disk. This is EXTREMELY slow. Even using
> ENVI's spectral tiling routines (which at least minimize the memory used,
> and allow me to know what line I'm on), I still have to parse an entire BIP
> or BIL file and rewrite it, when all I want to do is write to a specific
> line and leave the rest of them as is. Anyone have any suggestions for how
> to do this?
>
> --j
Hi Jonathon,
Looks like the rest of the World's gone to sleep, so I'll hazard a
guess.
Firstly though, I don't use ENVI, and hadn't even heard of BIP/BIL
files
until now... ;-)
But I gather that they're bitmap image files from ArcView.
What using ASSOC? ASSOC reads records as defined by you directly from
the file. In the code below, c:\image.dat was crated with :-
loadct,5
image = dist(400,400)
openw,lun,'c:\image.dat',/get
writeu,lun,image
free_lun,lun
Now you can read back in any line or block of lines using ASSOC, and
change
it too! The ASSOC variable is *not* held in memory, but read from the
disk
every time it is referenced.
PRO assoc_test
loadct,5
OpenU,lun,'c:\image.dat',/get
line = ASSOC(lun,bytarr(400))
print,line(199)
line(199) = BYTARR(400)
print,'=========================================='
print,line(199)
Free_lun,lun
END
And now you can independently read in image.dat and confirm the change.
Hardest part is defining the structure and any offset peculiar to your
file.
I hope I'm not woofing at the wrong piece of bark here...
Merry Xmas,
Andrew
|
|
|