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