On May 20, 12:59 pm, mengran <mengra...@gmail.com> wrote:
> Hi,everybody,
> I have got a annoying problem about the implementing the
> Savitzky-Golay filter to smooth the time series RS data in the IDL.
> Actually, I know the function of the Savitzky-Golay filter in IDL is
> SAVGOL.But the question is the result I got is either a horizon line
> or the same as the original line(In other words, the filter seems not
> to work at all), when I changed the parameters of the SAVGOL function.
> (when the DEGREE = NL + NR(PARA OF THE SAVGOL FUNCTION), THE RESULT
> IS THE SAME AS THE ORIGINAL, OTHERWISE, THE RUSULT IS A HORISON LINE)
> My pro is as follows. The class1 to class9 from txt files are
> the samples of the time series RS data.
> Is there sth wrong with my code ? Or the RS data that I used
> is not appropriate for the Savitzky-Golay filter, and I take a wrong
> method to smooth data ? I need your suggestions, thanks a lot !
>
> PRO Savgol_example
>
> ;RESTORE, 'C:\WorkSpace\Default\myPlotTemplate.sav'
> rootPath = 'C:\WorkSpace\Default\class'
>
> n = 1 & filename = strarr(9)
> for i = 0, 8 do begin
>
> filename[i] = strjoin([rootPath, strtrim(n, 2),'.txt'])
> n++
>
> endfor
> for i = 0,8 do begin
>
> plotTemplate = ASCII_TEMPLATE(filename[1])
> y1 = READ_ASCII(filename[1], TEMPLATE = plotTemplate, COUNT =
> $ count,NUM_RECORDS = 46 )
> x = indgen(46)
> iPlot,x,y1.FIELD1, NAME = 'Original Curve', $
> COLOR=[255, 0, 0], SYM_INDEX = 4, yrange = [0,+8000], VIEW_TITLE =
> strmid(filename[1], 21, 6)
> void = ITGETCURRENT(TOOL=oTool)
> void = oTool->DoAction('Operations/Insert/Legend')
>
> ; savgol
> savgolFilter = SAVGOL(2, 2, 0,4)
> iPlot,x,CONVOL(y1.FIELD1, savgolFilter), /OVERPLOT, $
> COLOR=[0, 0, 255], THICK=2, $
> NAME='Savitzky-Golay'
> void = oTool->DoAction('Operations/Insert/LegendItem')
> ;SAVE, plotTemplate, FILENAME='C:\WorkSpace\Default
> \myPlotTemplate.sav'
>
> endfor
>
> END
Hi Mengran,
I have an implementation of the Savitsky-Golay filter in IDL/ENVI
based on this paper:
Jin Chen, Per. Jonsson, Masayuki Tamura, Zhihui Gu, Bunkei
Matsushita, Lars Eklundh. 2004.
A simple method for reconstructing a high-quality NDVI time-series
data set based on
the Savitzky–Golay filter. Remote Sensing of Environment 91: 332–344
If you are interested I can send you the code.
Allard
|