From: Michael B. <mic...@gm...> - 2009-01-10 09:46:49
|
2009/1/10 Martin Desruisseaux <mar...@ge...>: > > The inconvenient of the default implementation of the Convolve operator is that > if we use a kernel of said 4x4 and if there is only 1 NaN value among the 16 > pixels under that kernel, then we get NaN. So we can loose a lot of area that > way. We could create a variant of the Convolve operator where NaN values are > ignored instead than summed. > > Does it fit your use case? > > Martin > Yes, I work with some data that are (monitoring woodland clearing and thinning) very similar to your examples in having various categories of nodata: clouds, inapplicable areas, and areas with high uncertainty ascribed to the classification. So if I am attempting to calculate local losses over time I have the similar issues to you with how to control the convolution process. Then there is another project where I am working on simulations of animal populations where the summed value of habitat resources available to an animal is constrained by the presence of other animal territories. In the present code for the modified convolve operator there are two 'mask' options: one which controls the positioning of the kernel and the other which controls which source pixels are considered by the kernel. At the moment the operator only uses one controlling image (an ROI object) for both options, but this would be easy to modify. You could have the operator accept multiple ROIs, e.g. one to exclude pixels where convolution isn't required / valid and a second to filter source pixels that should not contribute to the kernel sum. In the latter case it might also be useful to have the option of generating another output image to record the number or proportion of non-zero kernel position that were available (unmasked) for each destination pixel. One can also imagine making the operator (or probably a second operator) use a set of rules prescribing how to respond to source image values directly rather than using separate controlling images. I imagine this would result in slow processing - but it would avoid the need to construct ROIs or similar so might be preferable in some cases such as your example of differently valued NaNs in a source image. What do you think ? Michael |