I would like to ask a question about the proper way to calculate the Dice coefficient for an image dataset. We know that the Dice coefficient is calculated via the following equation:
$$Dice = \frac{TP +TP}{TP +TP +FP +FN}$$
However, how do we calculate the mean Dice coefficient for the entire dataset ? For example, suppose we have $N$ images, each having size $(H, W)$. There might be two ways:
We calculate the Dice coefficient for each image, and then take the average for all images
We flatten all of them into an array of size $N \times H \times W$, then calculate the Dice coefficient for this array.
I do not know which way is usually used in medical image segmentation. I have tried to search for some papers, but they do not go into details about this. It would be great if someone could reference some paper about this.