I don't actually understand the basics behind working with images but i can help you with the mask.
If you can create a matrix that is the same size as your tree image, and it will contain only zero and ones you can tell matlab to check only the cells that have a one in them. That is the only mask i know.
Is this the solution you want?
If you can create a matrix that is the same size as your tree image, and it will contain only zero and ones you can tell matlab to check only the cells that have a one in them. That is the only mask i know.
Is this the solution you want?