-
Notifications
You must be signed in to change notification settings - Fork 11
Added Richardson-Lucy deconvolution #8
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ac19331
Implemented Richardson-Lucy deconvolution
jakubwro 7171af5
Added newline
jakubwro 2662e3a
Update doc/lucy-cameraman.jl
jakubwro fe60f37
More spectacular lucy example
jakubwro a79409c
Documentation for lucy
jakubwro 5cf6cd9
Broken link fix
jakubwro ff09c01
Wrong wording fix
jakubwro ca91103
Merging transition to Documenter.jl
jakubwro afd2668
Merge branch 'master' of https://github.com/JuliaDSP/Deconvolution.jl…
jakubwro 5853019
Merge branch 'master' of https://github.com/jakubwro/Deconvolution.jl
jakubwro 6557a4a
Readded lucy docs
jakubwro 77977db
Wording change in lucy docs
jakubwro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*.jl.cov | ||
*.jl.*.cov | ||
*.jl.mem | ||
/doc/_build/ | ||
/doc/build/ | ||
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
using Images, TestImages | ||
using Deconvolution | ||
using FFTW | ||
using ZernikePolynomials #https://github.com/rdoelman/ZernikePolynomials.jl | ||
|
||
img = channelview(testimage("cameraman")) | ||
|
||
blurring = evaluateZernike(LinRange(-16,16,512), [12, 4, 0], [1.0, -1.0, 2.0], index=:OSA) | ||
blurring = fftshift(blurring) | ||
blurring = blurring ./ sum(blurring) | ||
|
||
blurred_img = fft(img) .* fft(blurring) |> ifft |> real | ||
|
||
@time result_200_iterations = lucy(blurred_img, blurring, iterations=200) | ||
@time result_2000_iterations = lucy(blurred_img, blurring, iterations=2000) | ||
|
||
(N, M) = size(blurred_img) | ||
|
||
out = ((vcat(hcat(img, ones(M, 20), blurred_img), | ||
ones(20, 2M+20), | ||
hcat(result_200_iterations, ones(M, 20), result_2000_iterations)))) | ||
|
||
save("lucy-cameraman.jpg", Images.clamp01nan.(out)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 |
---|---|---|
|
@@ -16,5 +16,6 @@ module Deconvolution | |
using FFTW | ||
|
||
include("wiener.jl") | ||
include("lucy.jl") | ||
|
||
end # module |
This file contains hidden or 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,49 @@ | ||
### lucy.jl --- Lucy deconvolution | ||
# | ||
# Copyright (C) 2019 Jakub Wronowski. | ||
# | ||
# Maintainer: Mosè Giordano <mose AT gnu DOT org> | ||
# Keywords: richadson, lucy, deconvolution, signal processing | ||
# | ||
# This file is a part of Deconvolution.jl. | ||
# | ||
# License is MIT "Expat". | ||
# | ||
### Commentary: | ||
# | ||
# This file provides the `lucy' function to perform Richardson-Lucy deconvolution. | ||
# | ||
### Code: | ||
|
||
export lucy | ||
|
||
function lucy(observed::AbstractArray, psf::AbstractArray; iterations::Integer = 1) | ||
@assert size(observed) == size(psf) | ||
@assert iterations >= 0 | ||
|
||
psf_ft = fft(psf) | ||
psf_ft_conj = conj.(psf_ft) | ||
|
||
function lucystep(e) | ||
return e .* real(ifft(fft(observed ./ ifft(fft(e) .* psf_ft)) .* psf_ft_conj)) | ||
end | ||
|
||
estimated = observed | ||
for i in 1:iterations | ||
estimated = lucystep(estimated) | ||
end | ||
|
||
return estimated | ||
end | ||
|
||
""" | ||
lucy(observed, psf[, iterations]) | ||
|
||
Returns the Richardson-Lucy deconvolution of `observed`, using the point spread | ||
function `psf`. | ||
|
||
All arguments must be arrays in the time/space domain and all of the same size, | ||
they will be converted into the frequency domain internally using the `fft` | ||
function. | ||
""" | ||
lucy |
This file contains hidden or 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
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.
@abhishalya , Documenter uses different output folder and .gitignore should be changed. Sorry for not catching that during review.
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.
Ah, right. Sorry I missed that too. Thanks for correcting that :)