I wanted to ensure the correctness of notation regarding some concepts of digital images. If I have a binary image $X$ of width $W$ and height $H$ is the correct notation for describing image $X$: $$X \in \{0, 1\}^{W\text{x}H}$$
Also, I have seen the definition of the Dice Score using the set notation for binary images but I still cant find the sense of it using sets:
$$\frac{2 \mid X \cap Y \mid}{\mid X \mid + \mid Y \mid}$$
Since $\mid X \mid$ and $\mid Y \mid$ express the cardinality, as I understand, these will be the total number of pixels and not the non-zero pixels. Note: The other definition posted in the link makes absolute sense; I just want to understand if the set definition can also, in some way, be extended for images.
There is no single correct notation. Often images are defined as a function on a discrete domain $D \in \mathbb{Z}^2$.
But when talking about binary images as sets, only the true (foreground) pixels are considered part of the set. So the cardinality of the binary image set is the number of true (foreground) pixels. This explains the Dice score definition.