{"id":48503928,"url":"https://github.com/antonmilev/magicinpainter","last_synced_at":"2026-04-07T15:37:06.351Z","repository":{"id":65779534,"uuid":"592912327","full_name":"antonmilev/MagicInpainter","owner":"antonmilev","description":"Image Inpaint Software","archived":false,"fork":false,"pushed_at":"2024-10-27T18:38:32.000Z","size":91826,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-03T06:52:43.543Z","etag":null,"topics":["image-analysis","image-processing","image-reconstruction","inpaint","remove-objects"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonmilev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-24T19:57:30.000Z","updated_at":"2024-10-31T07:30:30.000Z","dependencies_parsed_at":"2023-02-23T03:00:19.319Z","dependency_job_id":"e104952e-00bf-4647-bf40-92e75e4febb4","html_url":"https://github.com/antonmilev/MagicInpainter","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":0.09615384615384615,"last_synced_commit":"93dd767a9d1ecb1bb4ff099ee734d283c534af2d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/antonmilev/MagicInpainter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmilev%2FMagicInpainter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmilev%2FMagicInpainter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmilev%2FMagicInpainter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmilev%2FMagicInpainter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonmilev","download_url":"https://codeload.github.com/antonmilev/MagicInpainter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonmilev%2FMagicInpainter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31518631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["image-analysis","image-processing","image-reconstruction","inpaint","remove-objects"],"created_at":"2026-04-07T15:37:05.558Z","updated_at":"2026-04-07T15:37:06.339Z","avatar_url":"https://github.com/antonmilev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\n\u003cb\u003eMagicInpainter 3.0\u003c/b\u003e  is image processing tool for inpaint, mask selection and objects removal of small and medium sized objects from photos. Starting with version 3.0 GPU optimized image inpaint algorithms are used. \n\n\u003cb\u003eInpaint\u003c/b\u003e (or image reconstruction) is a process of filling in the missing parts of images in a natural way, preserving textures and background so that a person is not able to spot the difference. \n\u003cbr\u003e\n\nHistorically, there are two main groups of modern image inpaint methods:\n\n- **Image processing gradient algorithms (called also traditional)**\n- **Generative Deep Learning using neural networks with CNNs, etc. (called also AI methods)**\n\n\nAs shown below gradient methods in OpenCV are good only for small linear scratches, DL also has quality issues. MagicInpainter, on the other hand, employs \u003cb\u003estatistical methods\u003c/b\u003e, which can offer great flexibility in solving various problems. However, compared to the legacy gradient-based methods, one drawback of statistical approaches is the potentially high computational complexity. Therefore, significant challenge lies in optimizing performance. \n\n\n# Inpaint Algorithms\n\n\u003cb\u003eMagicInpainter 3.0\u003c/b\u003e fills in the pixels from the missing noisy regions using the data from the undamaged area in the same image, also called \u003cb\u003elow noise\u003c/b\u003e area. Training, preprocessing or additional images are not necessary. Inpain\\t is done only with extracting valid image data from the image area with \u003cb\u003elow noise\u003c/b\u003e and then using this data to fill in areas with \u003cb\u003ehigh noise\u003c/b\u003e. This is done with assigning each pixel or group of several pixels to the so-called \u003cb\u003eimage keys\u003c/b\u003e or as some researchers call them \u003cb\u003eimage features\u003c/b\u003e. Image keys are extracted from the non-noisy pixels neighborhood and then used to find the best match for the corresponding noisy pixels. Thus, like many other problems for inpaint we use a \u003cb\u003efeature space\u003c/b\u003e composed from the collected before \u003cb\u003evalid image keys\u003c/b\u003e. So the process of extracting image keys can be called constructing the feature space and inpaint is then can be called the process of \u003cb\u003edecreasing image noise\u003c/b\u003e using this feature space. \n\nSome of the parameters of the inpaint (available in Settings):\n\n- **Low noise and high noise area**\nWe first separate image into two regions – \u003cb\u003elow noise\u003c/b\u003e and \u003cb\u003ehigh noise\u003c/b\u003e, then we take pixels from the low noise area and fills in the pixels from the high noise area going from outside to inside. Choosing the objects for removal is done manually with applying a mask, MagicInpainter 3.0 has \u003cb\u003eEraser Button\u003c/b\u003e allowing to apply such mask over any part of the image. \n\n- **Max. Noise**\nIn some cases pixels close to the image edges or with too many noise around can distort results. This parameter is given in percents and controls which feature keys from the low noise area can be used during the inpaint, \u003cb\u003evalid image keys\u003c/b\u003e are these for which is fullfiled:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"figs/maxnoise.png\" width=\"150px\"/\u003e\n\u003c/p\u003e\n\n- **Zoom In/Out** For images with higher resolution generated feature keys are too many,\nit makes it more difficult and too computationally expensive to find a best match. To resolve this MagicInpainter provides the \u003cb\u003eZoom In\u003c/b\u003e and \u003cb\u003eZoom Out\u003c/b\u003e buttons and one parameter called \u003cb\u003eMax. Distance\u003c/b\u003e. \n\n- **Inpaint Radius** This radius controls the size of the area around each noise pixel, it would be used from the inpaint filter. Usually this is called filter \u003cb\u003ekernel radius\u003c/b\u003e and is given in pixels. Filter has kernel matrix with size \u003cb\u003e[2R+1]\u003c/b\u003e X \u003cb\u003e[2R+1]\u003c/b\u003e. Using larger inpaint radius means that pixels further away will participate in the reconstruction but just increasing \u003cb\u003eR\u003c/b\u003e does not always means better quality.\n\n# Reconstructing Image Patterns\n\n\u003cb\u003eMagicInpainter 3.0\u003c/b\u003e uses inpaint filters to find the best replacement candidates for the noisy pixels . For the calculation of inpaint pixels replacements sometimes are used gradient based methods, the most well-known of these is the Navier-Stokes method, described in the paper \u003ci\u003e\"Navier-Stokes, Fluid Dynamics, and Image and Video Inpainting\"\u003c/i\u003e, by Bertalmio, Marcelo, Andrea L. Bertozzi, and Guillermo Sapiro, published in 2001. This was further improved with the so called \u003cb\u003eFast Marching Method\u003c/b\u003e, representing successive fill-in from outside to inside of the noisy region, described in another famous paper \"An Image Inpainting Technique Based on the Fast Marching Method\" by Alexandru Telea, published in 2004 \n[[See]](https://www.researchgate.net/publication/238183352_An_Image_Inpainting_Technique_Based_on_the_Fast_Marching_Method). These are the only inpaint algorithms provided currently by OpenCV (See https://docs.opencv.org/3.4/df/d3d/tutorial_py_inpainting.html). My tests however showed that these methods, even as sufficiently fast are good only for small linear scratches and failed to reproduce the picture patterns even for small rectangular inpaint regions.\n\nOne other approach is to use GPU optimized variations of the \u003cb\u003eNormalized Cross Correlation\u003c/b\u003e calculation methods. These methods are widely used in the Forensic Tampering detection and elsewhere, [[See]](https://isas.iar.kit.edu/pdf/SPIE01_BriechleHanebeck_CrossCorr.pdf). The idea is to divide the image in blocks and to estimate the cross correlation as described in the paper \u003ci\u003e\"A Scaling Robust Copy-Paste Tampering Detection for Digital Image Forensics\"\u003c/i\u003e [[See]](https://www.researchgate.net/publication/300079866_A_Scaling_Robust_Copy-Paste_Tampering_Detection_for_Digital_Image_Forensics), with the normalized cross correlation coefficient as given by:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"figs/Fig2.png\" width=\"450px\"/\u003e\n\u003c/p\u003e\n\nSimilar approach can be applied but in reverse, instead of searching for forged content to reconstruct already known masked regions.   However, one drawback is that it is quite computational expensive, even with the proposed optimizations. One other optimization is called the \u003cb\u003eFast Template Matching\u003c/b\u003e method as described in [this](http://scribblethink.org/Work/nvisionInterface/vi95_lewis.pdf) paper , but there are many others. An open research in \u003cb\u003eMagicInpainter 3.0\u003c/b\u003e is how to further improve the inpaint algorithms to work with bigger resolutions and inpaint radius (see \u003cb\u003eFuture Work\u003c/b\u003e section below). \n\n\n# Test Results\n\n\u003cp\u003e\nFor removing medium sized object from some real-life photos like beach photos, inpaint quality is comparable with the AI apps available on net (after several passes):\n\u003c/p\u003e\n\n| \u003cimg src=\"test/beach/beach1.jpg\" width=\"200px\"/\u003e |  \u003cimg src=\"test/beach/beach1_inpaint_MI_r15.jpg\" width=\"200px\"/\u003e | \u003cimg src=\"test/beach/snapedit_1674688053397_pass2.jpg\" width=\"200px\"/\u003e | \u003cimg src=\"test/beach/beach1_adobe_PS_2023.jpg\" width=\"200px\"/\u003e | \n|---|---|---|---|  \n| *\u003cb\u003eOriginal Image, 862x400\u003c/b\u003e* | *\u003cb\u003eMagicInpainter 3.0, R15\u003c/b\u003e* | *\u003cb\u003eSnapEdit, pass 2\u003c/b\u003e* | *\u003cb\u003eAdobe PS 2023\u003c/b\u003e* |\n\n\n| \u003cimg src=\"test/beach3/beach.jpg\" width=\"200px\"/\u003e |  \u003cimg src=\"test/beach3/beach_inpain_MI_R25.jpg\" width=\"200px\"/\u003e | \u003cimg src=\"test/beach3/snapedit_1674692213009.jpg\" width=\"200px\"/\u003e | \u003cimg src=\"test/beach3/beach_adobe_PS_2023.jpg\" width=\"200px\"/\u003e | \n|---|---|---|---| \n| *\u003cb\u003eOriginal Image, 750x500\u003c/b\u003e* | *\u003cb\u003eMagicInpainter 3.0, R25\u003c/b\u003e* | *\u003cb\u003eSnapEdit, pass 2\u003c/b\u003e* | *\u003cb\u003eAdobe PS 2023\u003c/b\u003e* |\n\n\nSee Also: \n\u003cbr\u003e\n[Tests with Textures](test/TexturesResults.md) \n\u003cbr\u003e\n[Image Tampering Test](test/InpaintChallenge1.md) \n\n\n# Limitations\n\nMagicInpainter 3.0 works very well with textures and other pictures but data from other photos is not used and reconstruction of complex features, especially in photos with large sizes, may not be correct. For images with higher resolution, when noise area is large, reconstruction would be too slow, several repeats of “zoom and mask” would be necessary to fill in the missing content. \n\n\n# Future Work\nIn comming releases there would be several improvements:\n\n- **GPU performance** - several optimizations are possible for the GPU to work even faster, also search algorithms can be greately improved\n\n- **Images with larger resolution**\nOptimization algorithms used in MagicInpainter 3.0 become sometimes too slow and unstable for images with high resolution (in these cases \u003cb\u003eZoom In/Out\u003c/b\u003e buttons can be used). One other limitation is that inpaint radius can not exceed \u003cb\u003e64\u003c/b\u003e pixels. \n\n\n- **Processing several images and video**\nMagicInpainter 3.0 is currently limited to single photos.\n\n- **Use AI and deep learning to speed up algorithms and optimal inpaint radius selection**\nAssist inpaint algorithms with AI for classification, automation of algorithms type and optimal radius size selection. Used here inpaint algorithms can be combined with various neural networks models, especially in the cases when inpaint involves complicated features and big resolution, speed can be also significantly improved. \n\nFollowing research areas are also interesting for me:\n\n\n\u003cul\u003e\n  \u003cli\u003eVideo reconstruction \u003c/li\u003e\n  \u003cli\u003eTextures and artificial images generation\u003c/li\u003e\n  \u003cli\u003eNoise removal\u003c/li\u003e\n  \u003cli\u003eNoise Detection\u003c/li\u003e\n  \u003cli\u003eDeblur\u003c/li\u003e\n  \u003cli\u003eImage Tampering Analysis\u003c/li\u003e\n  \u003cli\u003eSuperposition\u003c/li\u003e\n  \u003cli\u003eSuperresolution\u003c/li\u003e\n  \u003cli\u003eStable Diffusion\u003c/li\u003e\n\u003c/ul\u003e \n\nNoise removal for example can be done with improving image quality using partial inpaint and weights coefficients rather than filling in the missing data with masks having only two values.\n\n# Python\n\nThere is also a Python library exporting the used inpaint methods:\n\u003cbr\u003ehttps://github.com/antonmilev/magicinpaintpython\n\n\n# Updates\n\n\u003cb\u003e Version 3.1.190 (from July 2023)\u003c/b\u003e\n\u003cul\u003e \n \u003cli\u003e Bugfixes\n \u003cli\u003e Limitation of the image sizes is removed!\n \u003cli\u003e The new \u003cb\u003eGPU Fast\u003c/b\u003e patch-matching algorithm is up to 5 times faster which allows processing of HD images :\n\nSee:\n[Comparison between GPU and GPU Fast performance](GPUPerformance.md) \n\u003c/ul\u003e \n\n\n\n# Release\n\n\u003cb\u003eMagicInpainter 3.0 \u003c/b\u003ecan be installed from: \n|CPU Version (\u003cb\u003e3.1.190\u003c/b\u003e)|  [MagicInpainter.msi](install/MagicInpainter.msi)|\n|---|---|\n|GPU Version (\u003cb\u003e3.1.190\u003c/b\u003e) | [MagicInpainterGpu.msi](install/MagicInpainterGpu.msi)|\n|User Manual| [Magic Inpainter 3.0.pdf](docs/MagicInpainter3.0.pdf)|\n\n\u003cp\u003e\u003cb\u003eMagicInpainter 3.0\u003c/b\u003e is free for personal and non-comercial use. It is provided in two versions for CPU amd GPU. I strongly recommend using the GPU version, it works better and faster, But for this you need NVIDIA GTX or RTX video card with CUDA support (10x,11x,12x). I tested the GPU app successfully on (GTX1050,RTX2070,RTX3050TI and RTX3060), with CUDA 10.1, 10.2 and 11.8 runtime. If you install the GPU version there is option in Settings to switch back to CPU.\u003c/p\u003e\n\n\u003cp\u003e\u003cb\u003eIf you do not have NVIDIA GPU card and installed CUDA driver (GTX or RTX) the GPU version of the application  will not work!\u003c/b\u003e\u003c/p\u003e \n\n\u003cp\u003e\u003cb\u003eMagicInpainter 3.0\u003c/b\u003e and all related source and documentation is provided under GNU GPLv3 public license.\u003c/p\u003e\n\n\u003cp\u003e\nSupported OS:  \u003cb\u003eWindow 7/Vista/10/11 x64\u003c/b\u003e\n\u003c/p\u003e  \n\n\u003cp\u003e\nFor introduction please see: https://youtu.be/RXDDdDnvNPY \n\u003c/p\u003e  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmilev%2Fmagicinpainter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonmilev%2Fmagicinpainter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonmilev%2Fmagicinpainter/lists"}