If you're trying to do this in a pixel shader, and doing the full conversion between linear and sRGB in real time is hard, you can use approximate sRGB as gamma 2. To convert to linear power, square it (power = value*value), and then to convert back, take the square root (value = power * rsqrt(power)). This is
fast on GPUs because they have a dedicated instruction for reciprocal square root (
rsqrt(x) = x
-1/2) for use in lighting and other calculations that use unit normal vectors. If you want to prototype your algorithm in a well-known image editor before you write code, the equivalent operation in GIMP or Photoshop is applying Levels with gamma 0.5, doing your blurring or scaling, and then applying Levels with gamma 2.