Let $f: [0, l]\times[0,l] \rightarrow [0,1]$ continuous. I need a mathematical tool to obtain a 'measure' of the contour lines of $f$, where 'measure' could be meant as their length. I was not able to find any answer in the literature.
Edited out after answers : [I was thinking about defining a function $g:[0,1]\rightarrow \mathbb{R}$ such that: $$ g(z) = \int_0^l\int_0^l\delta(f(x,y) - z)\,\text{d}x\text{d}y\quad, $$ where $\delta(\cdot)$ is the Dirac Delta function. Has it a mathematical meaning? Is there a more formal way to tackle this problem?]
Edit: Following @Mathemagical answer, I still have some doubts. For example: $f:[−2,2]\times[−2,2]\rightarrow[0,1]$,
$$ f(x,y) = \begin{cases} \max(0,−\sqrt(x^2+y^2)+2)\qquad \text{if }\sqrt(x^2+y^2) > 1\\ 1\qquad \text{otherwise} \end{cases} $$ (basically, a flipped truncated cone). Areas are $\pi(2-z)^2$ and $m=2\pi(z−2)$. Firstly, for $z\in[0,1]$, $m<0$, consistent with decreasing areas but, being interested in a positive metric, I guess I should consider the absolute value. Secondly, what about $z=0$ and $z=1$? In the first case, I would like $m = 16 - 4\pi$ (area outside the basis circle) and in the second case $m = \pi$, (area of the plateau). Am I wrong somewhere?
It seems that you have already defined a measure (the length), and are merely looking for a formula to express that.
Perhaps you would have wanted to use a 2 dimensional Dirac Delta function in some way? As written now, it is clearly a one-dimensional DD function. And for that, an integral over an area (a double integral) is not defined.
Edited out after comments: [I don’t really know your context, but is the area enclosed by the contour line also a possible measure? $$g(z) = \mu(f \ge z) = \int \int \mathbb{1}_{f>z}$$ where $ \mathbb{1}_{f>z}$ is a function that is 1 where $f>z$ and zero elsewhere. ]
For what you said you wanted, a better metric is not the length but the following one.
Let $a(z)$ be the area enclosed by the contour line, i.e, the area where $f>z$. Then the metric we want is simply the absolute value of the derivative $$m= \left|\frac{da}{dz}\right|$$ Why this and not the length? Because this captures not “how many points in the domain take the value z” (which, if it is a curve, is always a measure zero set) but “on how much of the domain is f in the vicinity of z?” (Between $z$ and $z+dz$).
In other words, $$da=|a(z+ dz)-a(z)|=|\frac{a(z+ dz)-a(z)}{dz}dz|$$ But $$\lim_{dz\rightarrow 0} \frac{a(z+ dz)-a(z)}{dz}= \frac{da}{dz}$$ so that $$da \approx m dz$$ for finite $dz$. This is why I have suggested $m \varepsilon $ as a measure in the comments.
I wish I could draw a figure to explain this, but I am writing this on a phone, so I cannot. Happy to explain this a little more if you aren’t able to see that after you try some examples. Maybe an example like $f=(\frac{x+y}{\sqrt{2}})^2$ will make it clear. The lengths of the curves where $f=0.0625$ and $f=0.5625$ is the same but the area of the domain where $0.0624<f<0.0626$ is much bigger than the area of the domain where $0.5624<f<0.5626$.
As a bonus area is often easier to compute than the length directly.
Example: let $f=xy$ on your domain. Then $$a=\int_z^1 \int_{\frac{z}{x}}^1 dy dx=1-z+z \ln z$$ So $$m=\ln z$$
I have assumed above that the function does not plateau anywhere. (The inverted cone you mention would work fine if it were not truncated).
If, otoh, your function purely has level sets that are areas (non-zero measure in two dimensions), not curves, the problem is also very easy. Each value of z would be associated with a specific area.
However, if, as I understand from your comments, the function is a mix of both, neither a simple function (taking only a ‘finite’ number of platueax) nor a function that never takes a plateau, both measures are invalid on some part of the domain.
In that case, does it make sense for you to stick to an area measure (so, for a plateau at z, you would report the area and for the rest, you would just say zero, instead of reporting the length or the variant that I proposed. Because that would be “combining apples and oranges”.