Setting different colors to differences between two images
Posted: 2018-06-13T02:19:31-07:00
Trying to find the difference between two image and display image1 differences in Red and the image2 in blue. Basically the first image is the older one and image2 is the newer image, so we want to see what has been removed in red and what has been added in blue. If we use the composite so the image combined would show the pixels that didn't change in the original grey scale or could be black. When we use the following code there are a lot of edges that come as slightly change because the pixels might be off slightly. I assume we would use fuzz to remove some of this, but I don't know how.
Using vb.net to program and using version 7.4.3.0
Here is my latest attempt and it seems to show some changes in yellow and blue for the new additions. most of the lines are showing a yellow pixelation with alot of the lines even though their isn't a difference between the images. These images are plans for a building so it is typically lines of black and some greyscale.
Using vb.net to program and using version 7.4.3.0
Here is my latest attempt and it seems to show some changes in yellow and blue for the new additions. most of the lines are showing a yellow pixelation with alot of the lines even though their isn't a difference between the images. These images are plans for a building so it is typically lines of black and some greyscale.
Code: Select all
Using image1 As New MagickImage(CurrentBitmap)
Using image2 As New MagickImage(PreviousBitmap)
Dim diffImage = New MagickImage()
Dim overlayBytes As Byte()
Dim s As New CompareSettings
s.HighlightColor = MagickColor.FromRgba(0, 0, 255, 180) 'setting Red color to be the Highlighted color
s.LowlightColor = MagickColor.FromRgba(0, 0, 0, 180)
image1.Compare(image2, s, diffImage)
image1.Composite(diffImage, CompositeOperator.Difference)
Dim overlayStream As New MemoryStream()
image1.Write(overlayStream, MagickFormat.Jpeg)
overlayBytes = overlayStream.ToArray()
overlayStream.Close()
Response.Clear()
Response.ClearHeaders()
Response.ClearContent()
Response.Buffer = True
Response.ContentType = "image/jpeg"
If Request.Headers.Item("User-Agent").Contains("Edge") AndAlso IsNothing(Request.Headers.Item("GetContentFeatures.DLNA.ORG")) Then
Dim bTemp As Byte()
Response.BinaryWrite(bTemp) 'Empty output
Response.Flush()
Response.SuppressContent = True
HttpContext.Current.ApplicationInstance.CompleteRequest()
End If
'Normal process:
Response.AddHeader("Content-Disposition", "filename=""" & Session("FileName") & ".jpg""")
Response.AddHeader("Content-Length", overlayBytes.Length)
Response.BinaryWrite(overlayBytes.ToArray())
Response.Flush()
Response.End()
End Using
End Using