1

My purpose is to use the 5*5 median filter to fill the vacant values of the image. There are two methods I found: 1.ee.Image.reduceNeighborhood() 2.ee.Image.focal_mean() Specifically, I think my correct parameters should be set like this, is this correct? '''

    var neighborImg = img.reduceNeighborhood({
                                  reducer: ee.Reducer.median(),
                                  kernel: ee.Kernel.square({radius: 2.5, 
                                  units: 'pixels', 
                                  normalize: false}),})
    //the 2.5 is right for 5*5? and the false of normalize is right?
    var neighborImg = img.focal_median(2.5, 'square', 'pixels')

I don't understand the difference between these two methods.

1 Answer 1

0

No significant difference. The reducers "min, max, mean, mode and median" occur so frequently that they often have their own shortcut functions (e.g.: collection.min, etc). There's a little more control in how things get run when you're using the reduce* function (e.g.: you can specify optimizations).

But the focal_* functions just eventually call the same code.

2
  • Thanks for your explanation, I also want to know, for a 5*5 window, is it correct to set the radius to 2.5?
    – guoyan
    Nov 22 at 1:49
  • Yes. But, if you're using a rectangular kernel, then 2 and 2.5 will produce the same size kernel. Nov 23 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.