Hi Jonathan,
ENVI won't do this for you. (I haven't checked 3.6, but previous versions won't.)
My impression is that ENVI's I/O philosophy is always "process to a new file".
But you can most probably do this with IDL code. It goes against the grain of letting ENVI handle your file I/O, but I think it's what you've got to do if you want to edit small bits of an image efficiently. The "flatter" your image the easier it'll be. (e.g., if the image on disk is pretty much exactly like how it ends up in memory then you're away.)
I can't go into great detail because of all of the variables, but here's the general idea:
1] Get image info on the open image with ENVI_FILE_QUERY. (Full filename, Data type, file type, organisation, header bytes etc). You'd probably want to cop out if the image is in-memory, the organisation is 'bsq' or the image type isn't ENVI standard.
2] Close the image with ENVI_FILE_MNG.
3] Open the image file with IDL's OPENU,UUPD,FILENAME,/GET_LUN.
4] Navigate to the line that you want to zap with IDL's POINT_LUN. Basically just skip over the initial header (if any) and as many image lines as necessary. (POINT_LUN works with byte offsets. For huge images you can give it 64-bit offsets like 99999999999LL - on some platforms at least. One line's worth of BIL or BIP image is NS*NB*BPE, where BPE is bytes-per-element for the image's datatype and it's something you'll have to come up with yourself. It's pretty straightforward, though. e.g., 1 for byte, 2 for int, 4 for long and float, 8 for double...)
5] Declare an array for a line of image. For a BIP image it would be LINE=MAKE_ARRAY(NB,NS,type=DT) and for BIL it would be LINE=MAKE_ARRAY(NS,NB,type=DT). (DT is the datatype from ENVI_FILE_QUERY.)
6] Save the file pointer with POINT_LUN,-UUPD,PSAVE. (Note -UUPD not UUPD.) Or just save the offset that you used in 4].
7] Read the line with READU,UUPD,LINE.
8] Do the necessary.
9] Restore the file pointer with POINT_LUN,UUPD,PSAVE.
10] Write the line with WRITEU,UUPD,LINE
11] Close the file with FREE_LUN,UUPD.
12] Re-open the file in ENVI with ENVI_OPEN_FILE,FILENAME. (FILENAME from ENVI_FILE_QUERY in 1].)
If you do several lines it might be an idea to use IDL_FILEFLUSHUNIT(UUPD) after each write, but it's probably unnecessary.
HTH
Cheers
Peter Mason
|