Re: Extracting average pixel value [message #66171] |
Fri, 24 April 2009 02:53  |
jameskuyper
Messages: 79 Registered: October 2007
|
Member |
|
|
Bennett wrote:
> On Apr 23, 1:00 pm, Bennett <juggernau...@gmail.com> wrote:
...
>> In IDL you can do a
>> newArray = CONVOL(imageArray, [[1,1,1],[1,0,1],[1,1,1]], /CENTER)
>> This will compute the average value in a 3x3 box around each pixel
>> (except
>> the edge pixels which you can set to zero or truncate or handle
>> separately...
>> whatever you please really. Who needs edges anyway, right?)
>>
>> Bennett
>
> I forgot to say also divide your resulting newArray by 8.
Alternatively, you could divide the array of weighting factors by 8.
|
|
|
Re: Extracting average pixel value [message #66174 is a reply to message #66171] |
Thu, 23 April 2009 10:11   |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Apr 23, 1:00 pm, Bennett <juggernau...@gmail.com> wrote:
> On Apr 22, 3:48 am, GP <gepo...@gmail.com> wrote:
>
>> Hello...
>
>> I have an .img file composed of 24 images (one every two weeks) and I
>> want to extract an spectral average pixel value for a 3x3 window with
>> the center pixel in sample=4567 and line 643.
>> Anyone know what would be the best approach to do this with IDL or
>> ENVI?
>
>> The .img file is a layer stacking... So the 24 images are represented
>> as "bands" if I open it with ENVI
>
>> Thanks in advance...
>> Geo
>
> In IDL you can do a
> newArray = CONVOL(imageArray, [[1,1,1],[1,0,1],[1,1,1]], /CENTER)
> This will compute the average value in a 3x3 box around each pixel
> (except
> the edge pixels which you can set to zero or truncate or handle
> separately...
> whatever you please really. Who needs edges anyway, right?)
>
> Bennett
I forgot to say also divide your resulting newArray by 8.
|
|
|
Re: Extracting average pixel value [message #66175 is a reply to message #66174] |
Thu, 23 April 2009 10:00   |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Apr 22, 3:48 am, GP <gepo...@gmail.com> wrote:
> Hello...
>
> I have an .img file composed of 24 images (one every two weeks) and I
> want to extract an spectral average pixel value for a 3x3 window with
> the center pixel in sample=4567 and line 643.
> Anyone know what would be the best approach to do this with IDL or
> ENVI?
>
> The .img file is a layer stacking... So the 24 images are represented
> as "bands" if I open it with ENVI
>
> Thanks in advance...
> Geo
In IDL you can do a
newArray = CONVOL(imageArray, [[1,1,1],[1,0,1],[1,1,1]], /CENTER)
This will compute the average value in a 3x3 box around each pixel
(except
the edge pixels which you can set to zero or truncate or handle
separately...
whatever you please really. Who needs edges anyway, right?)
Bennett
|
|
|
Re: Extracting average pixel value [message #66304 is a reply to message #66171] |
Mon, 04 May 2009 00:46  |
GP
Messages: 3 Registered: April 2009
|
Junior Member |
|
|
On Apr 24, 2:53 am, James Kuyper <jameskuy...@verizon.net> wrote:
> Bennett wrote:
>> On Apr 23, 1:00 pm, Bennett <juggernau...@gmail.com> wrote:
> ...
>>> In IDL you can do a
>>> newArray = CONVOL(imageArray, [[1,1,1],[1,0,1],[1,1,1]], /CENTER)
>>> This will compute theaveragevalue in a 3x3 box around each pixel
>>> (except
>>> the edge pixels which you can set to zero or truncate or handle
>>> separately...
>>> whatever you please really. Who needs edges anyway, right?)
>
>>> Bennett
>
>> I forgot to say also divide your resulting newArray by 8.
>
> Alternatively, you could divide the array of weighting factors by 8.
What do you think about this ENVI-approach to extract an average
window (profiled)
Once I open the stacked file (24 stacked layers) and get the id
lfile_id
...
arrayAvgYear = make_array(20,24, /float) ; ### ~ 24 periods per year
for 20 years.
noPixels = 9
countYear =0;
ENVI_FILE_QUERY, lfile_id, NS = ns, NL = nl, NB = nb, sname=sname,
interleave=interleave
pb= indgen(nb)
line1 = ENVI_GET_SLICE (fid = lfile_id, line=640,
pos=pb,xs=initSample, xe=lastSample )
line2 = ENVI_GET_SLICE (fid = lfile_id, line=641,
pos=pb,xs=initSample, xe=lastSample )
line3 = ENVI_GET_SLICE (fid = lfile_id, line=642,
pos=pb,xs=initSample, xe=lastSample )
For i=0, nb-1 Do Begin
arrayAvgYear[countYear,i] = (total(line1[*,i]) + total(line2[*,i])
+ total(line3[*,i])) / noPixels ;### Get the average for each image
of stacked layers
EndFor
countYear+=1 ;count for each year
fn+=1
IF (fn eq 2009) THEN BREAK
Endwhile
Then I just save the arrayAvgYear into a text file and I got a file
with one values for each year (every 14 days)
Date, Year1, Year2,... Year20
1, 0.3343, 0.233,
14, 0.3344, 0.334,
28, 0.3323, 0.344,
...
365
Any opinions...
Geo
|
|
|