mirror of
https://github.com/esimov/forensic.git
synced 2025-10-05 08:26:49 +08:00
Check blur radius
This commit is contained in:
12
main.go
12
main.go
@@ -144,10 +144,12 @@ func process(input image.Image, done chan struct{}) bool {
|
||||
draw.Draw(output, image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()), img, image.ZP, draw.Src)
|
||||
|
||||
// Blur the image to eliminate the details.
|
||||
blurImg := StackBlur(img, uint32(*blurRadius))
|
||||
if *blurRadius > 0 {
|
||||
img = StackBlur(img, uint32(*blurRadius))
|
||||
}
|
||||
|
||||
// Convert image to YUV color space
|
||||
yuv := convertRGBImageToYUV(blurImg)
|
||||
yuv := convertRGBImageToYUV(img)
|
||||
newImg := image.NewRGBA(yuv.Bounds())
|
||||
draw.Draw(newImg, image.Rect(0, 0, yuv.Bounds().Dx(), yuv.Bounds().Dy()), yuv, image.ZP, draw.Src)
|
||||
|
||||
@@ -182,7 +184,7 @@ func process(input image.Image, done chan struct{}) bool {
|
||||
for i := i0; i < i1; i += 4 {
|
||||
// Get the YUV converted image pixels
|
||||
yc, uc, vc, _ := b.Pix[i+0], b.Pix[i+2], b.Pix[i+2], b.Pix[i+3]
|
||||
// Convert YUV to RGB and obtain the R value
|
||||
// Convert YUV to RGB and obtain the R,G,B value
|
||||
r, g, b := color.YCbCrToRGB(yc, uc, vc)
|
||||
|
||||
for x := 0; x < *blockSize; x++ {
|
||||
@@ -268,6 +270,7 @@ func process(input image.Image, done chan struct{}) bool {
|
||||
forgedImg := image.NewRGBA(img.Bounds())
|
||||
overlay := color.RGBA{255, 0, 0, 255}
|
||||
|
||||
fmt.Println("Number of forged blocks detected: ", len(forgedBlocks))
|
||||
for _, bl := range forgedBlocks {
|
||||
draw.Draw(forgedImg, image.Rect(bl.xa, bl.ya, bl.xa+*blockSize*2, bl.ya+*blockSize*2), &image.Uniform{overlay}, image.ZP, draw.Over)
|
||||
}
|
||||
@@ -377,8 +380,6 @@ func filterOutNeighbors(vect []vector) (newVector, bool) {
|
||||
for i := 1; i < len(vect); i++ {
|
||||
blockA, blockB := vect[i-1], vect[i]
|
||||
|
||||
// Continue only if two regions are not neighbors.
|
||||
if blockA.xa != blockB.xa && blockA.ya != blockB.ya {
|
||||
// Calculate the euclidean distance between both regions.
|
||||
dx := float64(blockA.xa - blockB.xa)
|
||||
dy := float64(blockA.ya - blockB.ya)
|
||||
@@ -395,7 +396,6 @@ func filterOutNeighbors(vect []vector) (newVector, bool) {
|
||||
isForged = true
|
||||
}
|
||||
}
|
||||
}
|
||||
bar.Increment()
|
||||
}
|
||||
bar.Finish()
|
||||
|
Reference in New Issue
Block a user