there are two things not clear that can lead to miss-calculations.
One is if rgbAverage should be calculated pixel by pixel or for the whole image (proposed solution adopts pixel by pixel)
Second if rgbAverage (which is used to on saturation filter) should be calculated before applying any filter or after brightness and contrast filter since it is required for those filters to be applied before saturation filter (proposed solution adopts before)
Also verify correctness of proposed solution on second item
there are two things not clear that can lead to miss-calculations. One is if rgbAverage should be calculated pixel by pixel or for the whole image (proposed solution adopts pixel by pixel) Second if rgbAverage (which is used to on saturation filter) should be calculated before applying any filter or after brightness and contrast filter since it is required for those filters to be applied before saturation filter (proposed solution adopts before)
Also verify correctness of proposed solution on second item