- C#
式に問題があったので修正しました
- return Math.Pow((c_srgb + a / 1 + a ), 2.4 );
+ return Math.Pow(((c_srgb + a) / (1 + a) ), 2.4 );
using System;
using System.Collections.Generic;
using System.Linq;
public class App {
public static void Main(string[] args) {
int[] rgb = { 1, 1, 1};
double[] linearrgb = Array.ConvertAll(rgb,LinerRgb);
Array.ForEach(linearrgb, Console.WriteLine);
}
private static double LinerRgb(int c) {
double c_srgb = (double)c / 255;
double a = 0.055;
if ( c_srgb <= 0.04045 ) return c_srgb / 12.92;
return Math.Pow(((c_srgb + a) / (1 + a) ), 2.4 );
}
}
- python
def linearrgbg(c):
c_srgb = c / 255
a = 0.0555
if c_srgb <= 0.4045:
return c_srgb / 12.92
return math.pow(((c_srgb + a) / (1 + a) ), 2.4 )
if __name__ == '__main__':
rgb = [1,1,1]
linearrgbg = list(map(linearrgbg, rgb))
print(linearrgbg)
参考: sRGB - Wikipedia