mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Former-commit-id: 584e0dbc90cb5fbdc8d7d103dfc4c1d6716a726d Former-commit-id: 15bb157c19f09ee87889512a686b2b92deca44e7 Former-commit-id: ac3d596ab00ba5f1184edda33db8ec616f6797f9pull/1/head
12 changed files with 378 additions and 1 deletions
@ -0,0 +1,32 @@ |
|||
// <copyright file="Achromatomaly.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness.
|
|||
/// </summary>
|
|||
public class Achromatomaly : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = .618f, |
|||
M12 = .163f, |
|||
M13 = .163f, |
|||
M21 = .320f, |
|||
M22 = .775f, |
|||
M23 = .320f, |
|||
M31 = .062f, |
|||
M32 = .062f, |
|||
M33 = .516f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
// <copyright file="Achromatopsia.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness.
|
|||
/// </summary>
|
|||
public class Achromatopsia : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = .299f, |
|||
M12 = .299f, |
|||
M13 = .299f, |
|||
M21 = .587f, |
|||
M22 = .587f, |
|||
M23 = .587f, |
|||
M31 = .114f, |
|||
M32 = .114f, |
|||
M33 = .114f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
// <copyright file="ColorBlindness.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
/// <summary>
|
|||
/// Enumerates the various types of color blindness.
|
|||
/// </summary>
|
|||
public enum ColorBlindness |
|||
{ |
|||
/// <summary>
|
|||
/// Partial color desensitivity.
|
|||
/// </summary>
|
|||
Achromatomaly, |
|||
|
|||
/// <summary>
|
|||
/// Complete color desensitivity (Monochrome)
|
|||
/// </summary>
|
|||
Achromatopsia, |
|||
|
|||
/// <summary>
|
|||
/// Green weak
|
|||
/// </summary>
|
|||
Deuteranomaly, |
|||
|
|||
/// <summary>
|
|||
/// Green blind
|
|||
/// </summary>
|
|||
Deuteranopia, |
|||
|
|||
/// <summary>
|
|||
/// Red weak
|
|||
/// </summary>
|
|||
Protanomaly, |
|||
|
|||
/// <summary>
|
|||
/// Red blind
|
|||
/// </summary>
|
|||
Protanopia, |
|||
|
|||
/// <summary>
|
|||
/// Blue weak
|
|||
/// </summary>
|
|||
Tritanomaly, |
|||
|
|||
/// <summary>
|
|||
/// Blue blind
|
|||
/// </summary>
|
|||
Tritanopia |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Deuteranomaly.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness.
|
|||
/// </summary>
|
|||
public class Deuteranomaly : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.8f, |
|||
M12 = 0.258f, |
|||
M21 = 0.2f, |
|||
M22 = 0.742f, |
|||
M23 = 0.142f, |
|||
M33 = 0.858f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Deuteranopia.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness.
|
|||
/// </summary>
|
|||
public class Deuteranopia : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.625f, |
|||
M12 = 0.7f, |
|||
M21 = 0.375f, |
|||
M22 = 0.3f, |
|||
M23 = 0.3f, |
|||
M33 = 0.7f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Protanomaly.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Protanopia (Red-Weak) color blindness.
|
|||
/// </summary>
|
|||
public class Protanomaly : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.817f, |
|||
M12 = 0.333f, |
|||
M21 = 0.183f, |
|||
M22 = 0.667f, |
|||
M23 = 0.125f, |
|||
M33 = 0.875f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Protanopia.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness.
|
|||
/// </summary>
|
|||
public class Protanopia : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.567f, |
|||
M12 = 0.558f, |
|||
M21 = 0.433f, |
|||
M22 = 0.442f, |
|||
M23 = 0.242f, |
|||
M33 = 0.758f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
Color blindness matrices adapted from and tested against: |
|||
|
|||
http://web.archive.org/web/20090413045433/http://nofunc.org/Color_Matrix_Library |
|||
http://www.color-blindness.com/coblis-color-blindness-simulator/ |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Tritanomaly.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness.
|
|||
/// </summary>
|
|||
public class Tritanomaly : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.967f, |
|||
M21 = 0.33f, |
|||
M22 = 0.733f, |
|||
M23 = 0.183f, |
|||
M32 = 0.267f, |
|||
M33 = 0.817f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// <copyright file="Tritanopia.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageProcessorCore.Filters |
|||
{ |
|||
using System.Numerics; |
|||
|
|||
/// <summary>
|
|||
/// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness.
|
|||
/// </summary>
|
|||
public class Tritanopia : ColorMatrixFilter |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public override Matrix4x4 Matrix => new Matrix4x4() |
|||
{ |
|||
M11 = 0.95f, |
|||
M21 = 0.05f, |
|||
M22 = 0.433f, |
|||
M23 = 0.475f, |
|||
M32 = 0.567f, |
|||
M33 = 0.525f |
|||
}; |
|||
|
|||
/// <inheritdoc/>
|
|||
public override bool Compand => false; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue