Turns color images into grayscale images using a specialized filter that makes the red eyes stand out brightly against their background..
More...
|
override unsafe void | ProcessFilter (UnmanagedImage sourceData, UnmanagedImage destinationData) |
| Process the filter on the specified image. More...
|
|
|
override Dictionary
< PixelFormat, PixelFormat > | FormatTranslations [get] |
| Format translations dictionary. More...
|
|
short | Algorithm [get, set] |
|
Turns color images into grayscale images using a specialized filter that makes the red eyes stand out brightly against their background..
Definition at line 15 of file RedEyeFilter.cs.
ImageResizer.Plugins.RedEye.RedEyeFilter.RedEyeFilter |
( |
| ) |
|
|
inline |
Initializes a new instance of the RedEyeFilter class.
Definition at line 32 of file RedEyeFilter.cs.
34 formatTranslations[PixelFormat.Format24bppRgb] = PixelFormat.Format8bppIndexed;
35 formatTranslations[PixelFormat.Format32bppRgb] = PixelFormat.Format8bppIndexed;
36 formatTranslations[PixelFormat.Format32bppArgb] = PixelFormat.Format8bppIndexed;
ImageResizer.Plugins.RedEye.RedEyeFilter.RedEyeFilter |
( |
short |
alg | ) |
|
|
inline |
Initializes a new instance of the RedEyeFilter class.
- Parameters
-
alg | The algorithm to use for filtering the image. |
Definition at line 44 of file RedEyeFilter.cs.
override unsafe void ImageResizer.Plugins.RedEye.RedEyeFilter.ProcessFilter |
( |
UnmanagedImage |
sourceData, |
|
|
UnmanagedImage |
destinationData |
|
) |
| |
|
inlineprotected |
Process the filter on the specified image.
- Parameters
-
sourceData | Source image data. |
destinationData | Destination image data. |
Definition at line 54 of file RedEyeFilter.cs.
56 int width = sourceData.Width;
57 int height = sourceData.Height;
59 int pixelSize = System.Drawing.Image.GetPixelFormatSize(sourceData.PixelFormat) / 8;
62 var algorithm = Algorithm;
65 int srcOffset = sourceData.Stride - width * pixelSize;
66 int dstOffset = destinationData.Stride - width;
69 byte* src = (byte*)sourceData.ImageData.ToPointer();
70 byte* dst = (byte*)destinationData.ImageData.ToPointer();
72 for (
int y = 0; y < height; y++) {
73 for (
int x = 0; x < width; x++, src += pixelSize, dst++) {
74 if (src[RGB.R] == 0)
continue;
77 *dst = (byte)Math.Max(src[RGB.R] - Math.Min(src[RGB.G], src[RGB.B]), 0);
78 }
else if (algorithm == 1) {
80 sum = (src[RGB.R] + src[RGB.G] + src[RGB.B]);
81 *dst = (sum != 0) ? (byte)(255 * src[RGB.R] / sum) : (byte)0;
82 }
else if (algorithm == 2) {
84 *dst = src[RGB.R] == 0 ? (byte)0 : (byte)Math.Min(255, Math.Max(0, ((float)(src[RGB.R] - Math.Max(src[RGB.G], src[RGB.B])) * 255.0F / (
float)src[RGB.R])));
85 }
else if (algorithm == 3) {
87 *dst = (byte)Math.Pow((Math.Max(0, (src[RGB.R] * 2 - src[RGB.G] - src[RGB.B]) / src[RGB.R])), 2);
89 }
else if (algorithm == 4) {
91 *dst = (byte)Math.Min(255, (src[RGB.R] * src[RGB.R] / (src[RGB.G] * src[RGB.G] + src[RGB.B] * src[RGB.B] + 14)));
97 }
else throw new NotImplementedException();
override Dictionary<PixelFormat, PixelFormat> ImageResizer.Plugins.RedEye.RedEyeFilter.FormatTranslations |
|
get |
The documentation for this class was generated from the following file: