1

There is a classified image in which each pixel has a class number. I want to select those pixels with the same class number. Then do some statistics such as mean for those selected pixels. How can I achieve this goal? Looking forward for your instruction!

1 Answer 1

5

Let's say your image has a band called 'class' and you want the pixels where the class is 3. Then you could write:

var onlyClass3Image = classifiedImage.updateMask(
  classifiedImage.select('class').eq(3));

.eq(3) computes an image which is 1 where the input pixel is 3 and 0 where it is not, which we then use as a mask to remove pixels from the original image.

1
  • Thank you for your instruction! That is exactly what I want! Commented May 2, 2020 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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