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

Image Binarization #201

Open
wants to merge 6 commits into
base: source
Choose a base branch
from

Conversation

ashwani-rathee
Copy link
Member

@ashwani-rathee ashwani-rathee commented Jul 2, 2021

  • Supposed to provide demonstrations and examples for ImageBinarization.jl

Status : Early Stage, Not Ready

Preview Link :

Knowingly/unknowingly, current version does show http related methods and metaprogramming support usage here which might be a good thing.

Notes:

  • To binarize a brain scan(.nii)(3d image), needs to be figured out
  • ImageMagick.load loses a lot of detail this way of url download
using HTTP, ImageMagick

function get_image(url)
    response = HTTP.get(url)
    buffer = IOBuffer(response.body)
    img = ImageMagick.load(buffer)
end
# This returns a very bad image for some reason

Better method to download images

using Images
function get_image(url)
    img = mktemp() do fn, f
        download(url, fn)
        load(fn)
    end
    img_resized = imresize(img, ratio = 1 / 2)
end

img_coins = get_image("https://i.imgur.com/91IOKtJ.png")

@ashwani-rathee ashwani-rathee changed the title WIP: Image Binarization Image Binarization Jul 4, 2021
Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

I was expecting this demo to provide more information than https://zygmuntszpak.github.io/ImageBinarization.jl/dev/. But it turns out that it only
changes the input image?

The idea of solving sudoku sounds a great case to me but I didn't find the package OCReact

Comment on lines +49 to +71
algs = [
"AdaptiveThreshold",
"Balanced",
"Entropy",
"Intermodes",
"MinimumError",
"Moments",
"Niblack",
"Otsu",
"Polysegment",
"Sauvola",
"UnimodalRosin",
"Yen",
]
function binarize_methods(img_input, algs)
imgs_binarized = Array[]
for i in algs
alg = getfield(ImageBinarization, Symbol(i))()
img_input1 = binarize(img_input, alg)
push!(imgs_binarized, img_input1)
end
return imgs_binarized
end
Copy link
Member

Choose a reason for hiding this comment

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

What's the advantage of this compared to

algs = [AdaptiveThreshold(), Balanced(), Entropy(), Intermodes(),
        MinimumError(), Moments(), Niblack(), Otsu(),
        Polysegment(), Sauvola(), UnimodalRosin(), Yen()]
outs = map(alg->binarize(img, alg), algs)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't know we could make array of functions like this. Suggested version would be more concise then..

Comment on lines +91 to +93
# We can choose one of methods based on the results here, and use `OCReact.jl`
# which is based on Tesseract OCR to find the content in the sudoku and then
# solve the sudoku.
Copy link
Member

Choose a reason for hiding this comment

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

I can't find OCReact.jl in JuliaHub and GitHub.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think we should use https://github.com/pixel27/Tesseract.jl instead because it's backed by Tesseract_jll

Copy link
Member Author

Choose a reason for hiding this comment

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

OCReract.jl is better maintained I think, no updates in Tesseract.jl in last 15 months. But https://github.com/JuliaPackaging/Yggdrasil shows that Tesseract folder was updated in past 12 days. I don't know enough binary builds, so we can go for Tesseract.jl if you think that's a better option

Copy link
Member

Choose a reason for hiding this comment

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

OCReract.jl is better maintained I think

Nope, OCReract.jl requires the user to manually install Tesseract and make it available in PATH. While Tesseract.jl ships a prebuilt Tesseract using BinaryBuilder so that user just need pkg> add Tesseract and that's all.

@ashwani-rathee
Copy link
Member Author

ashwani-rathee commented Jul 25, 2021

Actually, there isn't much to add with what I know. I think we can add the build histogram(with its graph) and show the threshold..But it would require me to use plots here, which might slow things more I think

@johnnychen94
Copy link
Member

johnnychen94 commented Jul 25, 2021

I'm a little bit concerned about the current version because it adds basically nothing new compared to the existing index page of ImageBinarizations. The API itself is quite simple to understand and use.

I feel we need some application that uses ImageBinarization as a part of its pipeline. The sudoku solver sounds interesting, fingerprint enhancement together with ImageMorphology seems also a good candidate. How do you think?

@johnnychen94 johnnychen94 added the demo Ideas for demo/example to fulfill our gallery label Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo Ideas for demo/example to fulfill our gallery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants