public WavelengthCluster(SpectralDistribution spd, float[] ls) { LambdaStart = ls[0]; Values = new float[ls.Length]; Lambdas = ls.ToArray(); spd.Sample(ls.Length, ls, Values); }
public static RgbSpectrum ToRgb(SpectralDistribution spd) { var c = new RgbSpectrum(); float[] vc = new float[SampledSpectrum.nCIE]; spd.Sample(SampledSpectrum.nCIE, SampledSpectrum.CIE_lambda, vc); for (var i = 0; i < SampledSpectrum.nCIE; ++i) { float v = spd.Sample(i + SampledSpectrum.CIEstart); vc[i] = v; } /* for (var i = 0; i < SampledSpectrum.nCIE; ++i) { float v = spd.Sample(i + SampledSpectrum.CIEstart); c.c1 += v * SampledSpectrum.CIE_X[i]; c.c2 += v * SampledSpectrum.CIE_Y[i]; c.c3 += v * SampledSpectrum.CIE_Z[i]; }*/ c = new RgbSpectrum( SSE.VectorDot(vc, SampledSpectrum.CIE_X, 468), SSE.VectorDot(vc, SampledSpectrum.CIE_Y, 468), SSE.VectorDot(vc, SampledSpectrum.CIE_Z, 468)); var xyz = (c / 683f); float[] rgb; SampledSpectrum.XYZToRGB(xyz.ToArray(), out rgb); c = new RgbSpectrum(rgb); //res.GammaCorrection(); return c; }
public RgbSpectrum ToXyz(SpectralDistribution spd) { var c = new RgbSpectrum(); for (var i = 0; i < SampledSpectrum.nCIE; ++i) { float v = spd.Sample(i + SampledSpectrum.CIEstart); c.c1 += v * SampledSpectrum.CIE_X[i]; c.c2 += v * SampledSpectrum.CIE_Y[i]; c.c3 += v * SampledSpectrum.CIE_Z[i]; } var xyz = (c / 683f) * SampledSpectrum.yint; //(c / 300f); return xyz; }