Posts

Showing posts from June, 2017

Comparing two images and get difference image

The below steps describe how to compare tow images and get difference image Step 1: Get images to compare, both images shall be of same size  Dim sourceBitmap  As  Bitmap  =  PictureBox2 . Image  Dim destBitmap  As  Bitmap  =  PictureBox1 . Image   Step 2: Get byte array of each bitmap 2.1 Get first image byte array Dim sourceBitmapData As Imaging.BitmapData = sourceBitmap.LockBits(New Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height), Imaging.ImageLockMode.ReadOnly, Imaging.PixelFormat.Format32bppArgb)      Dim sourceBytes As Byte() = New Byte(sourceBitmapData.Stride * sourceBitmapData.Height - 1) {}          Runtime.InteropServices.Marshal.Copy(sourceBitmapData.Scan0, SourceBytes, 0, SourceBytes.Length)          sourceBitmap.UnlockBits(sourceBitmapData)     2.1 Get second image byte array   Dim destBitmapData  As  Imaging . BitmapData  =  destBitmap . LockBits (New  Rectangle ( 0 ,  0 ,  destBitmap . Width ,  destBitmap . Height ),  Imaging . ImageLockMode . Read