Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast Marching Method for Image Inpainting #663

Closed
wants to merge 666 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
666 commits
Select commit Hold shift + click to select a range
6f6d822
Fixed eikonal function's incorrect behavior.
chintak Jul 6, 2013
b3ab987
Creating a single pixel band
chintak Jul 6, 2013
da6d4da
Clean up _heap.py to have a single function `initialise` for flag, u …
chintak Jul 8, 2013
c437a6d
Documentation for the Fast Marching Method
chintak Jul 9, 2013
0719ec9
Documentation for `inpaint` function
chintak Jul 9, 2013
0af92ed
Documentation for the eikonal function
chintak Jul 9, 2013
de1fdee
Documentation for ep_neighbor function
chintak Jul 9, 2013
1f255e1
Minor doc addition
chintak Jul 9, 2013
d9fb50a
Documentation for inpaint_point function
chintak Jul 9, 2013
606152d
Documentation for grad_func function
chintak Jul 9, 2013
e82f3b6
Add return statement to initialise function
chintak Jul 9, 2013
6f39736
Update the citation
chintak Jul 9, 2013
a0f78c9
Implement using `initialise` function
chintak Jul 9, 2013
608053b
Different test case
chintak Jul 9, 2013
628f9d6
Better representation for the gradient function
chintak Jul 9, 2013
ff33c0c
Simplify docstrings and clarify some variable names
tonysyu Jul 10, 2013
770f1b5
Add distance/time map example
tonysyu Jul 10, 2013
db048d8
Implemented the heap structure using the in-built heapq function
chintak Jun 26, 2013
8b8cea6
Implemented the fast marching method code
chintak Jun 26, 2013
84cec39
Fixing PEP8 issues
chintak Jun 26, 2013
7dc0c6e
Added the grad_func
chintak Jun 28, 2013
17ac40a
Updated grad_func to support boundary condition
chintak Jun 28, 2013
a290813
Added negate parameter in fast_marching_method to work for FMM outsid…
chintak Jun 28, 2013
c9c0dcb
modified grad_func for generating gradient of u and image
chintak Jun 28, 2013
f16d573
Update the citation
chintak Jul 9, 2013
23bed28
Implement using `initialise` function
chintak Jul 9, 2013
3631f39
Different test case
chintak Jul 9, 2013
8404827
Better representation for the gradient function
chintak Jul 9, 2013
4990c8c
Simplify docstrings and clarify some variable names
tonysyu Jul 10, 2013
fc8e203
Important fix to speed up the code. Important bug fix for inappropria…
chintak Jul 10, 2013
8f74a0d
Show the order of FMM
chintak Jul 10, 2013
e48d411
Minor doc
chintak Jul 10, 2013
7a673e3
minor
chintak Jul 10, 2013
fa2eb0f
Doc and some code simplification
chintak Jul 12, 2013
96ca93d
Doc simplification
chintak Jul 12, 2013
8aa71e6
minor doc changes
chintak Jul 12, 2013
242c7c2
Cleaning `inpaint` function
chintak Jul 12, 2013
b3fd2d6
Inpaint without FMM outside
chintak Jul 12, 2013
056b5e3
Inpainting plugin
chintak Jul 12, 2013
fb4c493
Configuring the plugin
chintak Jul 12, 2013
da24f41
Tak einto account for the border case
chintak Jul 15, 2013
cb341dc
Minor: Test border case
chintak Jul 15, 2013
cf443c7
Cython implementation of _heap.py
chintak Jul 16, 2013
80e845c
Cython implementation
chintak Jul 17, 2013
102e5eb
Minor fix
chintak Jul 17, 2013
70f3cef
`grad_func` optimisation
chintak Jul 17, 2013
6703640
setup.py
chintak Jul 17, 2013
e46271c
`grad_func` and `inp_point` optimisations
chintak Jul 17, 2013
cd32a95
Configuring setup and test files
chintak Jul 18, 2013
b710b2c
Renaming cython_imp.pyx, and optimisation
chintak Jul 18, 2013
727a879
Workaround passing `image` and `u` to `grad_func`
chintak Jul 18, 2013
2e4e650
Use `cnp.float_t` consistently and Py_ssize_t for indices
chintak Jul 18, 2013
ef65ccc
Added unit test for inpainting
chintak Jul 20, 2013
2195084
Renamed _inpaint.py to py_inpaint.py
chintak Jul 20, 2013
83f1509
Unit test for fast marching method
chintak Jul 20, 2013
122627b
Profiling and Testing with the complete image
chintak Jul 20, 2013
b77f082
Minor name change
chintak Jul 21, 2013
42e11a4
Change definition of `ep_neighbor`
chintak Jul 21, 2013
fbfccc2
Major speed improvement: Get rid of `ep_neighbor` function and create…
chintak Jul 22, 2013
a0d1719
Rewrite `grad_func` and `inpaint_point` to avoid highly indented code
chintak Jul 22, 2013
f2c02c9
Change the data type from `cnp.int8` to `cnp.int16` to avoid overflow
chintak Jul 22, 2013
eea9ac1
Move `initialise` and `inpaint` function to inpaint.py; delete _heap.py
chintak Jul 22, 2013
4f4ebab
Clean directory: remove profile.py
chintak Jul 22, 2013
3b115ca
Use `skimage.viewer` to create an interactive inpainting interface
chintak Jul 22, 2013
3ae49db
Doc and indentation fixes
chintak Jul 22, 2013
41c5f6c
Move the code to `filter` package and demo_inpaint.py to `skimage.vie…
chintak Jul 22, 2013
7782b0f
Update setup.py in `skimage.filter` package
chintak Jul 22, 2013
130d369
Double ticks
chintak Jul 22, 2013
f86ae6f
Rename `neighbor` to `radius`, `channel` to `factor` and remove the `…
chintak Jul 23, 2013
82ad612
Variable changes; move `indices` to `fast_marching_method` function
chintak Jul 23, 2013
ad925d3
Added `inpaint_fmm` and `fast_marching_method` to __init__.py
chintak Jul 23, 2013
7999369
Modify `inpaint_fmm` to work without `_run_inpaint` parameter
chintak Jul 23, 2013
a3d1214
Fixed demo_inpaint.py and unit test
chintak Jul 23, 2013
0cea6a7
Major speed improvement: Use `np.float` as the data type for `image`
chintak Jul 23, 2013
01efcbf
Indentation
chintak Jul 23, 2013
7ae2408
Added an example in `doc/examples`
chintak Jul 23, 2013
7ef3e0b
Add `_inpaint` extension to bento.info
chintak Jul 23, 2013
51acccf
Improve docstring for ``inpaint_fmm`` function
chintak Jul 23, 2013
f481ff4
Use `np.ascontiguousarray` instead of `astype` attribute
chintak Jul 23, 2013
6f1b169
Greater accuracy on rounding; indentation
chintak Jul 24, 2013
5fd1488
Implemented the heap structure using the in-built heapq function
chintak Jun 26, 2013
7c2dd49
Added the inpainting function
chintak Jun 26, 2013
f2c8b46
Variable change
chintak Jun 28, 2013
562153a
Updated grad_func to support boundary condition
chintak Jun 28, 2013
57c4472
Denoting KNOWN as 0 and BAND by 1
chintak Jun 28, 2013
7ef5115
Removed the HeapElem class
chintak Jun 28, 2013
93d4461
Added generate_flags to __all__
chintak Jun 28, 2013
33dcc39
flag and u with 2 more rows and columns than the mask, for avoiding I…
chintak Jun 28, 2013
9f6a2ea
Mask already with 2 greater rows and columns as compared to initial i…
chintak Jun 28, 2013
1330024
Added the top level inpaint function
chintak Jun 28, 2013
0209b84
modified grad_func for generating gradient of u and image
chintak Jun 28, 2013
e766ca6
Created a new function for initialising u and renamed the generate_fl…
chintak Jun 28, 2013
983d984
Scalar Multiplication eq
chintak Jun 28, 2013
f2697f4
Minor fixes
chintak Jul 3, 2013
1aa5bdd
Test script
chintak Jul 4, 2013
66dd2f5
Replace `is` with `==` for comparison
chintak Jul 4, 2013
f662130
Use np.subtract for subtraction to avoid ubyte overflow
chintak Jul 4, 2013
bc4f2f3
imshow() to display the output
chintak Jul 4, 2013
701e1c4
Change for 1 channel test image
chintak Jul 4, 2013
73482d0
Convert input array to `int` type to avoid ubyte subtraction overflow
chintak Jul 4, 2013
6cc6a8c
Smaller test image
chintak Jul 4, 2013
9827057
Minor change
chintak Jul 4, 2013
861eca3
Using `dilation` to generate the band instead of `erosion`
chintak Jul 5, 2013
b2bf8b3
Display the initial, final and change images
chintak Jul 5, 2013
d35eb59
Hard code image for testing
chintak Jul 5, 2013
84e6fc1
Defined another function `ep_neighbor` to generate the epsilon neighb…
chintak Jul 5, 2013
fdfd9a9
Creating a single pixel band
chintak Jul 6, 2013
7644681
Clean up _heap.py to have a single function `initialise` for flag, u …
chintak Jul 8, 2013
4846970
Documentation for ep_neighbor function
chintak Jul 9, 2013
258b743
Documentation for inpaint_point function
chintak Jul 9, 2013
0c2c25f
Documentation for grad_func function
chintak Jul 9, 2013
195a2ba
Implement using `initialise` function
chintak Jul 9, 2013
5f509d0
Different test case
chintak Jul 9, 2013
3d6b866
Better representation for the gradient function
chintak Jul 9, 2013
39b937a
Simplify docstrings and clarify some variable names
tonysyu Jul 10, 2013
d9e34f3
Add distance/time map example
tonysyu Jul 10, 2013
f9616a4
Implemented the heap structure using the in-built heapq function
chintak Jun 26, 2013
7379544
Implemented the fast marching method code
chintak Jun 26, 2013
4527945
Added the inpainting function
chintak Jun 26, 2013
107f37d
Fixing PEP8 issues
chintak Jun 26, 2013
14badd4
Removed data attribute in HeapElem
chintak Jun 26, 2013
d573b47
Fixed PEP8 issues
chintak Jun 28, 2013
2e3e6ab
Added the grad_func
chintak Jun 28, 2013
f6809a8
Variable change
chintak Jun 28, 2013
9e47b4e
Updated grad_func to support boundary condition
chintak Jun 28, 2013
9a11f5d
Simplified eikonal_solve
chintak Jun 28, 2013
249cd39
Denoting KNOWN as 0 and BAND by 1
chintak Jun 28, 2013
84852f0
Removed the HeapElem class
chintak Jun 28, 2013
e25e015
Added generate_flags to __all__
chintak Jun 28, 2013
9e36a4d
flag and u with 2 more rows and columns than the mask, for avoiding I…
chintak Jun 28, 2013
55edb6c
Mask already with 2 greater rows and columns as compared to initial i…
chintak Jun 28, 2013
afa8c58
Added negate parameter in fast_marching_method to work for FMM outsid…
chintak Jun 28, 2013
1053726
Added the top level inpaint function
chintak Jun 28, 2013
6a9517c
modified grad_func for generating gradient of u and image
chintak Jun 28, 2013
2eb4999
Created a new function for initialising u and renamed the generate_fl…
chintak Jun 28, 2013
b772dd6
Scalar Multiplication eq
chintak Jun 28, 2013
d3dd762
Minor fixes
chintak Jul 3, 2013
7b224d9
Replaced `is` with `==` for comparison
chintak Jul 4, 2013
252d8ff
Test script
chintak Jul 4, 2013
58c27bd
Replace `is` with `==` for comparison
chintak Jul 4, 2013
ae944bb
Use np.subtract for subtraction to avoid ubyte overflow
chintak Jul 4, 2013
af6d203
imshow() to display the output
chintak Jul 4, 2013
c6e75cc
Change for 1 channel test image
chintak Jul 4, 2013
a089e38
Convert input array to `int` type to avoid ubyte subtraction overflow
chintak Jul 4, 2013
7d24c5b
Changes to include the BAND points as well
chintak Jul 4, 2013
9d7a582
Smaller test image
chintak Jul 4, 2013
c34d197
Minor change
chintak Jul 4, 2013
27cb3f0
Using `dilation` to generate the band instead of `erosion`
chintak Jul 5, 2013
04f88e6
To inpaint the outermost pixels of teh mask
chintak Jul 5, 2013
abfef09
Display the initial, final and change images
chintak Jul 5, 2013
5576976
Hard code image for testing
chintak Jul 5, 2013
dd134c4
Defined another function `ep_neighbor` to generate the epsilon neighb…
chintak Jul 5, 2013
5ad6250
Use camera image in example to check inpainting accuracy
tonysyu Jul 6, 2013
fe193d2
Clean up example names and simplify code
tonysyu Jul 6, 2013
d8d6832
Fixed eikonal function's incorrect behavior.
chintak Jul 6, 2013
2118731
Creating a single pixel band
chintak Jul 6, 2013
366f6b9
Clean up _heap.py to have a single function `initialise` for flag, u …
chintak Jul 8, 2013
ee87e13
Documentation for the Fast Marching Method
chintak Jul 9, 2013
cdc53a4
Documentation for `inpaint` function
chintak Jul 9, 2013
00e177b
Documentation for the eikonal function
chintak Jul 9, 2013
cf06767
Documentation for ep_neighbor function
chintak Jul 9, 2013
5bf2f71
Minor doc addition
chintak Jul 9, 2013
221588f
Documentation for inpaint_point function
chintak Jul 9, 2013
8163cbc
Documentation for grad_func function
chintak Jul 9, 2013
10beaa6
Add return statement to initialise function
chintak Jul 9, 2013
9510524
Update the citation
chintak Jul 9, 2013
afc5c79
Implement using `initialise` function
chintak Jul 9, 2013
c69d014
Different test case
chintak Jul 9, 2013
59d7f94
Better representation for the gradient function
chintak Jul 9, 2013
cd2501f
Simplify docstrings and clarify some variable names
tonysyu Jul 10, 2013
b32a7fa
Add distance/time map example
tonysyu Jul 10, 2013
ad04ade
Important fix to speed up the code. Important bug fix for inappropria…
chintak Jul 10, 2013
12fe269
Show the order of FMM
chintak Jul 10, 2013
520f540
Minor doc
chintak Jul 10, 2013
d2e1a0e
minor
chintak Jul 10, 2013
af6c4a9
Doc and some code simplification
chintak Jul 12, 2013
773d245
Doc simplification
chintak Jul 12, 2013
0edc807
minor doc changes
chintak Jul 12, 2013
89e1a8d
Cleaning `inpaint` function
chintak Jul 12, 2013
3ca551c
Configure to work with `fmm.inpaint`
chintak Jul 12, 2013
666ad35
Inpaint without FMM outside
chintak Jul 12, 2013
2976195
minor doc and remove comments
chintak Jul 12, 2013
759672a
Inpainting plugin
chintak Jul 12, 2013
f1533a2
Configuring the plugin
chintak Jul 12, 2013
359a0f7
Tak einto account for the border case
chintak Jul 15, 2013
89bb417
Minor: Test border case
chintak Jul 15, 2013
e9e9062
Cython implementation of _heap.py
chintak Jul 16, 2013
da4ea60
Cython implementation
chintak Jul 17, 2013
7e7dd73
Minor fix
chintak Jul 17, 2013
80ccd79
`grad_func` optimisation
chintak Jul 17, 2013
a766c77
setup.py
chintak Jul 17, 2013
77e9324
`grad_func` and `inp_point` optimisations
chintak Jul 17, 2013
6642eb5
Added unit test for inpainting
chintak Jul 20, 2013
2640ef2
Unit test for fast marching method
chintak Jul 20, 2013
486b6a0
Cleaning directory; only cython implementation of py_inpaint.py file …
chintak Jul 20, 2013
7304fc8
Cython implementation of `grad_func`, `ep_neighbor` and `inpaint_point`
chintak Jul 20, 2013
7f04712
Profiling and Testing with the complete image
chintak Jul 20, 2013
a4de025
Minor name change
chintak Jul 21, 2013
eb249d8
Change definition of `ep_neighbor`
chintak Jul 21, 2013
b3368db
Major speed improvement: Get rid of `ep_neighbor` function and create…
chintak Jul 22, 2013
799d186
Rewrite `grad_func` and `inpaint_point` to avoid highly indented code
chintak Jul 22, 2013
f3caa62
Change the data type from `cnp.int8` to `cnp.int16` to avoid overflow
chintak Jul 22, 2013
040da9a
Move `initialise` and `inpaint` function to inpaint.py; delete _heap.py
chintak Jul 22, 2013
d66c496
Clean directory: remove profile.py
chintak Jul 22, 2013
7bcff6b
Changes to accommodate the new directory structure
chintak Jul 22, 2013
6235328
Use `skimage.viewer` to create an interactive inpainting interface
chintak Jul 22, 2013
b2a0aa5
update __all__ in _inpaint.pyx
chintak Jul 22, 2013
d788886
Doc and indentation fixes
chintak Jul 22, 2013
6c3da02
Update setup.py in `skimage.filter` package
chintak Jul 22, 2013
c803a1b
Double ticks
chintak Jul 22, 2013
d30c721
Delete the `inpaint` directory
chintak Jul 23, 2013
30e7962
Rename `neighbor` to `radius`, `channel` to `factor` and remove the `…
chintak Jul 23, 2013
6aadbe9
Modify `inpaint_fmm` to work without `_run_inpaint` parameter
chintak Jul 23, 2013
ae75270
Fixed demo_inpaint.py and unit test
chintak Jul 23, 2013
d39bb23
Major speed improvement: Use `np.float` as the data type for `image`
chintak Jul 23, 2013
4f85198
Indentation
chintak Jul 23, 2013
9a720cc
Improve docstring for ``inpaint_fmm`` function
chintak Jul 23, 2013
aff8bc5
Greater accuracy on rounding; indentation
chintak Jul 24, 2013
64a0402
Add `skimage.filter`
chintak Jul 24, 2013
87a67e9
minor fix
chintak Jul 24, 2013
54c2be3
Change for Travis test
chintak Jul 24, 2013
957d748
Added example to ``inpaint_fmm``
chintak Jul 24, 2013
e3068f6
Fix ``TypeError`` for dimension of ``inpaint_mask``
chintak Jul 24, 2013
0d74371
Update docs
chintak Jul 24, 2013
50a0078
minor doc changes
chintak Jul 24, 2013
bbb76d0
Add error checks
chintak Jul 24, 2013
243a4ec
minor doc
chintak Jul 27, 2013
2f1e372
Rewrite gradient function to handle single dimension.
tonysyu Jul 31, 2013
1c5d14e
Update docs to incorporate Tony's suggestion
chintak Jul 31, 2013
afba89a
Remove initialisation details for u and heap from inapint_fmm
chintak Jul 31, 2013
4c2c0f5
Add comments
chintak Jul 31, 2013
ac19cc4
Remove start function and demo_time_fill
chintak Jul 31, 2013
6631f84
minor
chintak Jul 31, 2013
f5ba793
Undo `shifted_indices` change
chintak Jul 31, 2013
9026479
Change the test case
chintak Jul 31, 2013
197f32b
Remove the function from the example
chintak Jul 31, 2013
752b6d8
Prefix '_' to internal functions; change convention for ``_grad_func``
chintak Jul 31, 2013
6afd8d0
Undo indenting
chintak Jul 31, 2013
b740c85
Getting rid of all magic values and reusing BAND, INSIDE and LARGE_VA…
chintak Aug 1, 2013
000e913
Fix tests
chintak Aug 4, 2013
8506d32
Remove ``test_fmm``
chintak Aug 12, 2013
1af8310
Rename _inpaint.pyx as _inpaint_fmm.pyx and fast_marching_method a pr…
chintak Aug 12, 2013
3385107
Fix merge conflicts
chintak Aug 12, 2013
5a7111d
Fix setup.py file; Remove the additional files while fixing merge con…
chintak Aug 12, 2013
fe837d7
Update bento.info
chintak Aug 13, 2013
1488936
Fixes
chintak Aug 26, 2013
1306957
Add note for eikonal func
chintak Aug 31, 2013
2303740
opencv ref
chintak Sep 1, 2013
d259aaa
Minor doc
chintak Sep 5, 2013
e3625e5
Fixes
chintak Sep 27, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,6 @@ doc/source/auto_examples/applications/
doc/source/_static/random.js
.idea/
*.log
*.html
*.sh
*.prof
3 changes: 3 additions & 0 deletions bento.info
Expand Up @@ -138,6 +138,9 @@ Library:
Extension: skimage.filter.rank.bilateral_cy
Sources:
skimage/filter/rank/bilateral_cy.pyx
Extension: skimage.filter._inpaint_fmm
Sources:
skimage/filter/_inpaint_fmm.pyx

Executable: skivi
Module: skimage.scripts.skivi
Expand Down
37 changes: 37 additions & 0 deletions doc/examples/plot_inpaint_fmm.py
@@ -0,0 +1,37 @@
"""
===========================
Structural Image Inpainting
===========================

Image Inpainting is the process of reconstructing lost or deteriorated parts
of an image.

In this example we wll show Structural inpainting which uses geometric
approaches for filling in the missing information in the region which should
be inpainted. These algorithms focus on the consistency of the geometric
structure.

"""
import numpy as np
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a brief docstring explaining what you're trying to accomplish in this example. Take a look at the other examples and notice the docstring title, which gets rendered as the page title by Sphinx. Also, I would avoid writing out the algorithm in the example docstring, as done in PR #670.

import matplotlib.pyplot as plt
from skimage import data
from skimage.filter import inpaint


image = data.camera()
paint_region = (slice(240, 260), slice(360, 420))
paint_region1 = (slice(430, 450), slice(360, 410))

mask = np.zeros_like(image, dtype=np.uint8)
mask[paint_region] = 1
mask[paint_region1] = 1
image[mask == 1] = 0

painted = inpaint.inpaint_fmm(image, mask)

fig, (ax0, ax1) = plt.subplots(ncols=2)
ax0.set_title("Input Image")
ax0.imshow(image, cmap=plt.cm.gray)
ax1.set_title("Inpainted Image")
ax1.imshow(painted, cmap=plt.cm.gray)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd echo @sciunto's suggestion of adding short titles.

plt.show()
6 changes: 4 additions & 2 deletions skimage/filter/__init__.py
Expand Up @@ -2,14 +2,15 @@
from .ctmf import median_filter
from ._canny import canny
from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt,
hprewitt, vprewitt, roberts , roberts_positive_diagonal,
hprewitt, vprewitt, roberts, roberts_positive_diagonal,
roberts_negative_diagonal)
from ._denoise import denoise_tv_chambolle, tv_denoise
from ._denoise_cy import denoise_bilateral, denoise_tv_bregman
from ._rank_order import rank_order
from ._gabor import gabor_kernel, gabor_filter
from .thresholding import threshold_otsu, threshold_adaptive
from . import rank
from .inpaint import inpaint_fmm


__all__ = ['inverse',
Expand Down Expand Up @@ -38,4 +39,5 @@
'gabor_filter',
'threshold_otsu',
'threshold_adaptive',
'rank']
'rank',
'inpaint_fmm']