Created
August 20, 2013 08:30
-
-
Save sTiLL-iLL/6278704 to your computer and use it in GitHub Desktop.
Compare the color values of individual pixels by calculating the vector positioning between individual pixels within the standard ternary groupings "(R,G,B)".. Use this to detect nudity, etc...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe void sniffColors(Bitmap bmp, | |
byte r, byte g, int b, int heft) | |
{ | |
BitmapData dta = image.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), | |
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); | |
int bPxl=3; | |
byte* chk1=(byte*)imageData.Scan0.ToPointer(); | |
int trn=imageData.Stride; | |
int hgt=imageData.Height; | |
int wdt=imageData.Width; | |
int i, j=0; | |
byte er=0; | |
byte scs=255; | |
int mxHft=(heft * heft); | |
byte* lin; | |
for (;i<hgt;++i) | |
{ | |
lin = chk1+(i * trn); | |
for (j;j<wdt;++j) { | |
int rDx=bDx + 2; | |
int bDx=j * bPxl; | |
int gDx=bDx + 1; | |
byte pB=ln[bDx]; | |
byte pR=ln[rDx]; | |
byte pG=ln[gDx]; | |
int blDF=pB - b; | |
int rdDF=pR - r; | |
int gnDF=pG - g; | |
int lng=((rdDF * rdDF)+(gnDF * gnDF)+(blDF * blDF)); | |
((ln[rDx]=ln[bDx])=(ln[gDx]=lng)) > mxHft ? chk1 : scs; | |
} | |
} | |
image.UnlockBits(imageData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment