static protected byte[] NormalizeByBlur3(byte[] dataPixs, Rect rect, int bytePerPix, int kernelSize, float blurVar) { Dpu.ImageProcessing.Image blur = new Dpu.ImageProcessing.Image(kernelSize, kernelSize); Dpu.ImageProcessing.Image.Blur_Kernel(blur, 1.0F, blurVar, blurVar, true); Dpu.ImageProcessing.Image[] src = FaceSortUI.ImageUtils.ConvertByteArrayToImageArray(dataPixs, rect, bytePerPix); byte[] ret = new byte[(int)rect.Width * (int)rect.Height * (bytePerPix - 1)]; for (int ib = 1; ib < bytePerPix; ++ib) { Dpu.ImageProcessing.Image.Divide(src[ib], src[0], src[ib]); } int destOff = 0; Dpu.ImageProcessing.Image dest = new Dpu.ImageProcessing.Image((int)rect.Width, (int)rect.Height); Dpu.ImageProcessing.Image[] destArray = new Dpu.ImageProcessing.Image[1]; for (int ib = 1; ib < bytePerPix; ++ib) { Dpu.ImageProcessing.Image.ConvolutionReflecting(src[ib], 1, 1, blur, dest); //Dpu.ImageProcessing.Image.Subtract(src[ib], dest, dest); Dpu.ImageProcessing.Image.NormalizeMeanStdev(dest, 128, 32, dest); destArray[0] = dest; //destArray[0] = src[ib]; byte[] tmp = FaceSortUI.ImageUtils.ConvertImageArrayToByteArray(destArray); Array.Copy(tmp, 0, ret, destOff, tmp.Length); destOff += tmp.Length; } return(ret); }
static protected byte[] NormalizeByBlur(byte[] dataPixs, Rect rect, int bytePerPix, int kernelSize, float blurVar) { Dpu.ImageProcessing.Image blur = new Dpu.ImageProcessing.Image(kernelSize, kernelSize); Dpu.ImageProcessing.Image.Blur_Kernel(blur, 1.0F, blurVar, blurVar, true); Dpu.ImageProcessing.Image[] src = FaceSortUI.ImageUtils.ConvertByteArrayToImageArray(dataPixs, rect, bytePerPix); Dpu.ImageProcessing.Image dest = new Dpu.ImageProcessing.Image((int)rect.Width, (int)rect.Height); Dpu.ImageProcessing.Image.ConvolutionReflecting(src[0], 1, 1, blur, dest); Dpu.ImageProcessing.Image.Subtract(src[0], dest, dest); Dpu.ImageProcessing.Image.NormalizeMeanStdev(dest, 128, 32, dest); Dpu.ImageProcessing.Image[] destArray = new Dpu.ImageProcessing.Image[1]; destArray[0] = dest; byte[] ret = FaceSortUI.ImageUtils.ConvertImageArrayToByteArray(destArray); return(ret); }