comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Moment and XROI
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Moment and XROI [message #93345] Mon, 20 June 2016 11:04 Go to next message
roconnor is currently offline  roconnor
Messages: 2
Registered: June 2016
Junior Member
Hi everyone,

I'm stumped on this one. My aim is to "cut out" a region of an image (fits) and analyze only the data in that region. That works great when I use XROI and the statistics keyword. However, I would also like to use MOMENT to further analyze the data contained within the ROI. When I use MOMENT, however, the mean returned is very different than the mean returned by Statistics. Does anyone know why this is/how I could get MOMENT to analyze the data within the ROI?

Relevant snippet of code is below.

XROI, data, regions_out = thisROI, statistics=S, /block

mask = thisROI ->computemask(dimensions=size(data, /dimensions), mask_rule=2)

roiImage = data*(mask GT 0)
M = moment(roiImage)
tv, roiImage

PRINT, 'Count Min Max Mean StdDev'
PRINT, S
print, '*********************************************************** ****'
PRINT, 'Mean: ', M[0] & PRINT, 'Variance: ', M[1] & $
PRINT, 'Skewness: ', M[2] & PRINT, 'Kurtosis: ', M[3]
Re: Moment and XROI [message #93348 is a reply to message #93345] Mon, 20 June 2016 12:27 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Monday, June 20, 2016 at 2:04:10 PM UTC-4, roco...@smith.edu wrote:
>
> roiImage = data*(mask GT 0)
> M = moment(roiImage)

It looks like you are setting the values outside the mask to zero, but they are still included (as zeros) in the moment calculation. I think what you want is

goodpix = where(mask GT 0)
M = moment(roiImage[goodpix])

but I only took a quick look at the problem. --Wayne
Re: Moment and XROI [message #93349 is a reply to message #93348] Mon, 20 June 2016 12:47 Go to previous message
roconnor is currently offline  roconnor
Messages: 2
Registered: June 2016
Junior Member
On Monday, June 20, 2016 at 3:27:27 PM UTC-4, wlandsman wrote:
> On Monday, June 20, 2016 at 2:04:10 PM UTC-4, roco...@smith.edu wrote:
>>
>> roiImage = data*(mask GT 0)
>> M = moment(roiImage)
>
> It looks like you are setting the values outside the mask to zero, but they are still included (as zeros) in the moment calculation. I think what you want is
>
> goodpix = where(mask GT 0)
> M = moment(roiImage[goodpix])
>
> but I only took a quick look at the problem. --Wayne

That solved it! Thanks so much!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Compilation Error: Procedure header must appear first and onlyonce
Next Topic: NaN doesn't work!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:16:21 PDT 2025

Total time taken to generate the page: 0.00474 seconds