{"id":17189094,"url":"https://github.com/esimov/forensic","last_synced_at":"2025-03-17T11:30:28.534Z","repository":{"id":65711799,"uuid":"116419964","full_name":"esimov/forensic","owner":"esimov","description":"Copy-move image forgery detection library.","archived":false,"fork":false,"pushed_at":"2022-03-08T07:47:30.000Z","size":830,"stargazers_count":140,"open_issues_count":0,"forks_count":21,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-16T11:11:20.492Z","etag":null,"topics":["computer-vision","dct","digital-signal-processing","forgery-detection","golang","image-forensics","image-processing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esimov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"esimov"}},"created_at":"2018-01-05T19:34:28.000Z","updated_at":"2025-03-13T06:21:07.000Z","dependencies_parsed_at":"2023-02-06T04:25:13.314Z","dependency_job_id":null,"html_url":"https://github.com/esimov/forensic","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fforensic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fforensic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fforensic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esimov%2Fforensic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esimov","download_url":"https://codeload.github.com/esimov/forensic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244025162,"owners_count":20385529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","dct","digital-signal-processing","forgery-detection","golang","image-forensics","image-processing"],"created_at":"2024-10-15T01:10:43.682Z","updated_at":"2025-03-17T11:30:27.853Z","avatar_url":"https://github.com/esimov.png","language":"Go","funding_links":["https://github.com/sponsors/esimov"],"categories":[],"sub_categories":[],"readme":"# Forensic\r\n\r\n[![build](https://github.com/esimov/forensic/actions/workflows/build.yml/badge.svg)](https://github.com/esimov/forensic/actions/workflows/build.yml)\r\n[![license](https://img.shields.io/github/license/esimov/forensic)](./LICENSE)\r\n\r\nForensic is an image processing library which aims to detect copy-move forgeries in digital images. The implementation is mainly based on this paper: https://arxiv.org/pdf/1308.5661.pdf\r\n\r\n### Implementation details\r\n\r\n* Convert the `RGB` image to `YUV` color space.\r\n* Divide the `R`,`G`,`B`,`Y` components into fixed-sized blocks.\r\n* Obtain each block `R`,`G`,`B` and `Y` components.\r\n* Calculate each block `R`,`G`,`B` and `Y` components `DCT` (Discrete Cosine Transform) coefficients.\r\n* Extract features from the obtained `DCT` coefficients and save it into a matrix. The matrix rows will contain the blocks top-left coordinate position plus the DCT coefficient. The matrix will have `(M − b + 1)(N − b + 1)x9` elements.\r\n* Sort the features in lexicographic order.\r\n* Search for similar pairs of blocks. Because identical blocks are most probably neighbors, after ordering them in lexicographic order we need to apply a specific threshold to filter out the false positive detections. If the distance between two neighboring blocks is smaller than a predefined threshold the blocks are considered as a pair of candidate for the forgery.\r\n* For each pair of candidate compute the cumulative number of shift vectors (how many times the same block is detected). If that number is greater than a predefined threshold the corresponding regions are considered forged.\r\n\r\n## Install\r\nFirst install Go if you don't have already installed, set your `GOPATH`, and make sure `$GOPATH/bin` is in your `PATH` environment variable.\r\n\r\n```bash\r\n$ export GOPATH=\"$HOME/go\"\r\n$ export PATH=\"$PATH:$GOPATH/bin\"\r\n```\r\nNext download the project and build the binary file.\r\n\r\n```bash\r\n$ go get -u -f github.com/esimov/forensic\r\n$ go install\r\n```\r\n\r\nIn case you do not want to build the binary file yourself you can obtain the prebuilt one from the [releases](https://github.com/esimov/forensic/releases) folder.\r\n\r\n## Usage\r\n\r\n```bash\r\n$ forensic -in input.jpg -out output.jpg\r\n```\r\n\r\n### Supported commands:\r\n```bash \r\n$ forensic --help\r\n\r\nImage forgery detection library.\r\n    Version: \r\n\r\n  -blur int\r\n    \tBlur radius (default 1)\r\n  -bs int\r\n    \tBlock size (default 4)\r\n  -dt float\r\n    \tDistance threshold (default 0.4)\r\n  -ft float\r\n    \tForgery threshold (default 210)\r\n  -in string\r\n    \tInput image\r\n  -ot int\r\n    \tOffset threshold (default 72)\r\n  -out string\r\n    \tOutput image\r\n```\r\n\r\n## Results\r\n| Original image | Forged image | Detection result |\r\n| --- | --- | --- |\r\n| ![dogs_original](https://user-images.githubusercontent.com/883386/39047347-3fee70cc-44a2-11e8-8729-c4312c631017.jpg) | ![dogs_forged](https://user-images.githubusercontent.com/883386/39047218-c1c8c530-44a1-11e8-8eb6-f9a8470848bd.jpg) | ![dogs_result](https://user-images.githubusercontent.com/883386/39047481-aec6f0f0-44a2-11e8-9f0f-041b9f2a0eb4.png) |\r\n\r\n### Notice\r\nSometimes the library produces false positive results depending on the image content. For this reason I advise to adjust the settings. Also in some cases human judgement is required, but otherwise the library do a decent job in detecting forged images. \r\n\r\n### How to interpret the results?\r\nThe more intensive the overlayed color is, the more certain is that the image is tampered.\r\n\r\n## Author\r\n\r\n* Endre Simo ([@simo_endre](https://twitter.com/simo_endre))\r\n\r\n## License\r\n\r\nCopyright © 2018 Endre Simo\r\n\r\nThis project is under the MIT License. See the LICENSE file for the full license text.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fforensic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesimov%2Fforensic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesimov%2Fforensic/lists"}