/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Lms"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Lms"/></returns> public Lms ToLms(CieLuv color) { Guard.NotNull(color, nameof(color)); var xyzColor = this.ToCieXyz(color); return(this.ToLms(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieLchuv"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieLchuv"/></returns> public CieLchuv ToCieLchuv(CieLuv color) { // Adaptation CieLuv adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color; // Conversion return(CieLuvToCieLchuvConverter.Convert(adapted)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieLab"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieLab"/></returns> public CieLab ToCieLab(CieLuv color) { Guard.NotNull(color, nameof(color)); CieXyz xyzColor = this.ToCieXyz(color); return(this.ToCieLab(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Rgb"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Rgb"/></returns> public Rgb ToRgb(CieLuv color) { Guard.NotNull(color, nameof(color)); var xyzColor = this.ToCieXyz(color); return(this.ToRgb(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Hsl"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Hsl"/></returns> public Hsl ToHsl(CieLuv color) { Guard.NotNull(color, nameof(color)); var xyzColor = this.ToCieXyz(color); return(this.ToHsl(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Cmyk"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Cmyk"/></returns> public Cmyk ToCmyk(CieLuv color) { Guard.NotNull(color, nameof(color)); var xyzColor = this.ToCieXyz(color); return(this.ToCmyk(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="YCbCr"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="YCbCr"/></returns> public YCbCr ToYCbCr(CieLuv color) { Guard.NotNull(color, nameof(color)); var xyzColor = this.ToCieXyz(color); return(this.ToYCbCr(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieXyz"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieXyz"/></returns> public CieXyz ToCieXyz(CieLchuv color) { Guard.NotNull(color, nameof(color)); // Conversion to Luv CieLuv luvColor = CieLchuvToCieLuvConverter.Convert(color); // Conversion to XYZ (incl. adaptation) return(this.ToCieXyz(luvColor)); }
public void CieLuvConstructorAssignsFields() { const float l = 75F; const float c = -64F; const float h = 87F; var cieLuv = new CieLuv(l, c, h); Assert.Equal(l, cieLuv.L); Assert.Equal(c, cieLuv.U); Assert.Equal(h, cieLuv.V); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieXyz"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieXyz"/></returns> public CieXyz ToCieXyz(CieLuv color) { // Conversion CieXyz unadapted = CieLuvToCieXyzConverter.Convert(color); // Adaptation CieXyz adapted = color.WhitePoint.Equals(this.WhitePoint) || !this.IsChromaticAdaptationPerformed ? unadapted : this.Adapt(unadapted, color.WhitePoint); return(adapted); }
public void Convert_Lchuv_to_Luv(float l, float c, float h, float l2, float u, float v) { // Arrange CieLchuv input = new CieLchuv(l, c, h); // Act CieLuv output = Converter.ToCieLuv(input); // Assert Assert.Equal(l2, output.L, FloatRoundingComparer); Assert.Equal(u, output.U, FloatRoundingComparer); Assert.Equal(v, output.V, FloatRoundingComparer); }
public void Convert_Luv_to_LCHuv(float l, float u, float v, float l2, float c, float h) { // Arrange CieLuv input = new CieLuv(l, u, v); // Act CieLchuv output = Converter.ToCieLchuv(input); // Assert Assert.Equal(l2, output.L, FloatRoundingComparer); Assert.Equal(c, output.C, FloatRoundingComparer); Assert.Equal(h, output.H, FloatRoundingComparer); }
/// <summary> /// Converts a <see cref="CieLchuv"/> into a <see cref="CieLuv"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieLab"/></returns> public CieLuv ToCieLuv(CieLchuv color) { // Conversion (perserving white point) CieLuv unadapted = CieLchuvToCieLuvConverter.Convert(color); if (!this.IsChromaticAdaptationPerformed) { return(unadapted); } // Adaptation return(this.Adapt(unadapted)); }
public void CieLuvEquality() { var x = default(CieLuv); var y = new CieLuv(Vector3.One); Assert.True(default(CieLuv) == default(CieLuv)); Assert.False(default(CieLuv) != default(CieLuv)); Assert.Equal(default(CieLuv), default(CieLuv)); Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); }
public void Convert_Xyz_to_Luv(float x, float y, float z, float l, float u, float v) { // Arrange CieXyz input = new CieXyz(x, y, z); ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 }; // Act CieLuv output = converter.ToCieLuv(input); // Assert Assert.Equal(l, output.L, FloatRoundingComparer); Assert.Equal(u, output.U, FloatRoundingComparer); Assert.Equal(v, output.V, FloatRoundingComparer); }
/// <summary> /// Adapts <see cref="CieLchuv"/> color from the source white point to white point set in <see cref="TargetLabWhitePoint"/>. /// </summary> /// <param name="color">The color to adapt</param> /// <returns>The adapted color</returns> public CieLchuv Adapt(CieLchuv color) { if (!this.IsChromaticAdaptationPerformed) { throw new InvalidOperationException("Cannot perform chromatic adaptation, provide a chromatic adaptation method and white point."); } if (color.WhitePoint.Equals(this.TargetLabWhitePoint)) { return(color); } CieLuv luvColor = this.ToCieLuv(color); return(this.ToCieLchuv(luvColor)); }
public void Convert_Luv_to_Xyz(float l, float u, float v, float x, float y, float z) { // Arrange CieLuv input = new CieLuv(l, u, v, Illuminants.D65); ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 }; // Act CieXyz output = converter.ToCieXyz(input); // Assert Assert.Equal(x, output.X, FloatRoundingComparer); Assert.Equal(y, output.Y, FloatRoundingComparer); Assert.Equal(z, output.Z, FloatRoundingComparer); }
/// <summary> /// Adapts <see cref="CieLuv"/> color from the source white point to white point set in <see cref="TargetLuvWhitePoint"/>. /// </summary> /// <param name="color">The color to adapt</param> /// <returns>The adapted color</returns> public CieLuv Adapt(CieLuv color) { Guard.NotNull(color, nameof(color)); if (!this.IsChromaticAdaptationPerformed) { throw new InvalidOperationException("Cannot perform chromatic adaptation, provide a chromatic adaptation method and white point."); } if (color.WhitePoint.Equals(this.TargetLuvWhitePoint)) { return(color); } CieXyz xyzColor = this.ToCieXyz(color); return(this.ToCieLuv(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="LinearRgb"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="LinearRgb"/></returns> public LinearRgb ToLinearRgb(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToLinearRgb(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Cmyk"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Cmyk"/></returns> public Cmyk ToCmyk(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToCmyk(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Lms"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Lms"/></returns> public Lms ToLms(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToLms(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="HunterLab"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="HunterLab"/></returns> public HunterLab ToHunterLab(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToHunterLab(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieXyy"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieXyy"/></returns> public CieXyy ToCieXyy(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToCieXyy(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="CieLch"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="CieLch"/></returns> public CieLch ToCieLch(CieLuv color) { CieXyz xyzColor = this.ToCieXyz(color); return(this.ToCieLch(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="YCbCr"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="YCbCr"/></returns> public YCbCr ToYCbCr(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToYCbCr(xyzColor)); }
/// <summary> /// Converts a <see cref="CieLuv"/> into a <see cref="Hsl"/> /// </summary> /// <param name="color">The color to convert.</param> /// <returns>The <see cref="Hsl"/></returns> public Hsl ToHsl(CieLuv color) { var xyzColor = this.ToCieXyz(color); return(this.ToHsl(xyzColor)); }