This question is with reference to semantic segmentation.
we weight each pixel by
αc = median freq/freq(c)where freq(c) is the number of pixels of class c divided by the total number of pixels in images where c is present, and median freq is the median of these frequencies
However, I have some difficulty understanding what the author meant by:
"number of pixels of class c". Do they mean the number of pixels of class C in one image or in all images?
"The total number of pixels in images where c is present" - Do they mean the total number of pixels for each image is divided by the number of pixels of class c in that same image?
"median frequency is the median of these frequencies"
After reading the above, my impression of this concept takes the form of this implementation:
For each image, calculate the number of pixels C and divide it by the total number of pixels in the image. This will give you a frequency f_i
For each image, compute f_i and then sort it by ascending order, before getting the median frequency. This will give you median_freq
To compute freq(c), calculate the total number of c pixels in all images, and divide it by the total number of pixels in all images.
Finally, compute each pixel's weight according the formula.
Meaning to say the implementation calculates the median frequency of c, aka class c's presence in each image before dividing it by the average presence of class c in all images.
However, I don't think this implementation causes dominant labels to be weighted less, because if dominant labels are frequently present by the same amount and the mean is not too different from the median, then the weight will be roughly equal to 1. So how does this help in class balancing? Could someone clarify whether my implementation is correct or clarify this concept?