I have some data on regular structured grid and I need to estimate the normal to the geometry surface and the area at the nodes intersecting with the geometry.
as you can see in the image I want the surface area and normals of the geometry in this case the triangle in the image (interior points have values of zero and exteriors 1). I estimated the normals as the gradients as
where "C" is 1 outside the geometry and 0 inside it (see the top image).
I cannot figure out how to calculate surface area though. The reason is I want to then use the approach to do surface integrals like:
where P for example would be a field value which would be 0 inside the geomoetry as in the below image
Any comment is really appreciated.
EDIT
I managed to significantly improve the outer edge detection and normal calculations. Basically, I used a Gaussian filter to first smooth the color field. I then defined a band threshold to detect cells within the threshold as the edge cells. This combined with gradient estimation as before, resulted in very good surface normal estimations.