X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 30 Jul 2007 08:34 AM by  anon
Adding tiling to an ENVI/IDL program - smoothing/averaging HSI data
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
30 Jul 2007 08:34 AM
    I have code for IDL to smooth hyperspectral data by utilizing a moving average. I need to add a function to tile the information, because I am currently limited to what memory my computer has available (which isn't much). Alternatively, are there any modules in ENVI that can average spectra, because I have used the spatial smoothing functions, but perhaps there is a way to apply this to the spectral data? I've included my code below. Thanks! ============================================== xsz=400 ysz=400 zsz=354 factor=3 filename='D:\test\testfile' q=fltarr(xsz,ysz,zsz) openr,1,filename readu,1,q close,1 temp=fltarr(zsz) for i=0,xsz-1 do begin for j=0,ysz-1 do begin temp(*)=q(i,j,*) temp=smooth(temp,factor) q(i,j,*)=temp end ; for j end ;for i openw,2,filename+'_smth' writeu,2,q close,2 end

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Jul 2007 08:34 AM
    You should take a look at the two spectrally-oriented image tiling options available in ENVI. The first is a function called ENVI_GET_SLICE, which allows you to grab an entire line of data in BIP or BIL and have it returned as an array in IDL. The second involves three routines: ENVI_TILE_INIT, ENVI_GET_TILE, and ENVI_TILE_DONE. These three routines make up ENVI's main tiling capabilities. Like ENVI_GET_SLICE, you have a lot of control over how data are extracted from the image and returned via IDL arrays, but you can grab more than one line at a time..

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Jul 2007 08:34 AM
    I would definitely look at the tiling routines Devin mentioned, but you could also make the code you wrote much more efficient. The double for loop you use can be replaced by a single line of code. this single line is more speed optimized than your loops b/c loops are slow in IDL. It's also more memory optimized b/c of all the array indexing you do, and it also uses TEMPORARY() for a few extra memory gains. Have a look at this article for all the details: http://www.dfanning.com/code_tips/smthband.html Jeff
    You are not authorized to post a reply.