public int[] Projection(System.Drawing.Bitmap srcImage, double angle, Infrastructure.OrientationType orientType) { Byte[] rgbBytes = LockBits(srcImage, System.Drawing.Imaging.ImageLockMode.ReadWrite); Int32 singleWidth = RealWidth / 3; Int32 length = singleWidth * Height; Byte[] tempb = new Byte[length]; Byte[] tempg = new Byte[length]; Byte[] tempr = new Byte[length]; for (int i = 0; i < Height; i++) { for (int j = 0; j < singleWidth; j++) { tempb[i * singleWidth + j] = rgbBytes[i * Width + j * 3]; tempg[i * singleWidth + j] = rgbBytes[i * Width + j * 3 + 1]; tempr[i * singleWidth + j] = rgbBytes[i * Width + j * 3 + 2]; } } UnlockBits(rgbBytes); Int32[] resub, resug, resur; base.projection(ref tempb, singleWidth, Height, angle, orientType, out resub); base.projection(ref tempg, singleWidth, Height, angle, orientType, out resug); base.projection(ref tempr, singleWidth, Height, angle, orientType, out resur); Int32[] result = new Int32[resub.Length]; for (int i = 0; i < resub.Length; i++) { Int32 temp = resub[i] + resug[i] + resur[i]; result[i] = temp / 3; } return(result); }
int[] IBinarization.Projection(System.Drawing.Bitmap srcImage, double angle, Infrastructure.OrientationType orientType) { Byte[] rgbBytes = LockBits(srcImage, System.Drawing.Imaging.ImageLockMode.ReadWrite); Int32 singleWidth = RealWidth / 3; Int32 length = singleWidth * Height; Byte[] data = new Byte[length]; for (int i = 0; i < Height; i++) { for (int j = 0; j < singleWidth; j++) { data[i * singleWidth + j] = rgbBytes[i * Width + j * 3].Equals(Byte.MinValue) ? (Byte)1 : (Byte)0; } } UnlockBits(rgbBytes); Int32[] result; base.projectionV2(ref data, singleWidth, Height, angle, orientType, out result); return(result); }
int[] IBinarization.Projection(System.Drawing.Bitmap srcImage, Infrastructure.OrientationType orientType) { return(((IBinarization)this).Projection(srcImage, System.Math.PI / 2, orientType)); }