public Bitmap otsu_uygulama(Bitmap video) { Gri = new GreyScala(); // Hsvv = new Hsv_(); // int[] histogram1 = histogram(Gri.change_gray(Hsvv.ColorToHSV(video))); int[] histogram1 = histogram(Gri.change_gray((video))); int i = OtsuEsiginiBelirle(histogram1, video); Rectangle rect = new Rectangle(0, 0, video.Width, video.Height); System.Drawing.Imaging.BitmapData bmpData = video.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, video.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * video.Height; byte[] rgbValues = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); for (int counter = 0; counter < rgbValues.Length; counter += 3) { if (rgbValues[counter] < i) { rgbValues[counter] = 0; rgbValues[counter + 1] = 0; rgbValues[counter + 2] = 0; } else { rgbValues[counter] = 255; rgbValues[counter + 1] = 255; rgbValues[counter + 2] = 255; } } System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); video.UnlockBits(bmpData); GC.Collect(); return(video); }
public Form1() { InitializeComponent(); Gri = new GreyScala(); Otsu = new OtsuScala(); _LOCK = new object(); Finger = new FingerPrints(); parmak_bolge1 = new int[5]; ImageQueue = new ConcurrentQueue<Bitmap>(); ImageQueue_reel = new ConcurrentQueue<Bitmap>(); ImageQueue_reel1 = new ConcurrentQueue<Bitmap>(); ImageQueue_otsu = new ConcurrentQueue<Bitmap>(); ImageQueue_otsu1 = new ConcurrentQueue<Bitmap>(); ImageQueue_hand = new ConcurrentQueue<int[]>(); ImageQueue_hand1 = new ConcurrentQueue<int[]>(); ImageQueue_bolge = new ConcurrentQueue<int[]>(); ImageQueue_finger = new ConcurrentQueue<Bitmap>(); }
public Form1() { InitializeComponent(); Gri = new GreyScala(); Otsu = new OtsuScala(); _LOCK = new object(); Finger = new FingerPrints(); parmak_bolge1 = new int[5]; ImageQueue = new ConcurrentQueue <Bitmap>(); ImageQueue_reel = new ConcurrentQueue <Bitmap>(); ImageQueue_reel1 = new ConcurrentQueue <Bitmap>(); ImageQueue_otsu = new ConcurrentQueue <Bitmap>(); ImageQueue_otsu1 = new ConcurrentQueue <Bitmap>(); ImageQueue_hand = new ConcurrentQueue <int[]>(); ImageQueue_hand1 = new ConcurrentQueue <int[]>(); ImageQueue_bolge = new ConcurrentQueue <int[]>(); ImageQueue_finger = new ConcurrentQueue <Bitmap>(); }
public Bitmap otsu_uygulama(Bitmap video) { Gri=new GreyScala(); // Hsvv = new Hsv_(); // int[] histogram1 = histogram(Gri.change_gray(Hsvv.ColorToHSV(video))); int[] histogram1 = histogram(Gri.change_gray((video))); int i = OtsuEsiginiBelirle(histogram1 , video); Rectangle rect = new Rectangle(0, 0, video.Width, video.Height); System.Drawing.Imaging.BitmapData bmpData = video.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, video.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * video.Height; byte[] rgbValues = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); for (int counter = 0; counter < rgbValues.Length; counter += 3) { if (rgbValues[counter] < i) { rgbValues[counter] = 0; rgbValues[counter + 1] =0; rgbValues[counter + 2] = 0; } else { rgbValues[counter] = 255; rgbValues[counter + 1] = 255; rgbValues[counter + 2] = 255; } } System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); video.UnlockBits(bmpData); GC.Collect(); return video; }