Moment and XROI [message #93345] |
Mon, 20 June 2016 11:04  |
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 #93349 is a reply to message #93348] |
Mon, 20 June 2016 12:47  |
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!
|
|
|