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

Type is not preserved while saving bi-level/depth=1/binary images to file in png format. #232

Closed
arumugamav opened this issue Jul 19, 2019 · 0 comments · Fixed by JuliaIO/ImageMagick.jl#172

Comments

@arumugamav
Copy link

Objective: To save image in bi-level format as demonstrated at https://memorynotfound.com/convert-image-black-white-java/

Code:

using Images, ImageView;

function save_as_binary_image(img_path::String, threshold::Float16)
    img_binary = load(img_path);
    img_binary = (Gray.(img_binary) .> threshold);
    imshow(img_binary);
    typeof(img_binary);#=>BitArray{2}
    save("/path/to/dest/image.png", img_binary);
    img_saved = load("/path/to/dest/image.png");
    imshow(img_saved);
    typeof(img_saved);#=>Array{Gray{Normed{UInt8,8}},2}
end

save_as_binary_image("/path/to/image/file", convert(Float16, 0.5));

It saves as image of depth 8 but not of depth 1. It may please be resolved!

timholy added a commit to JuliaIO/ImageMagick.jl that referenced this issue Dec 12, 2019
timholy added a commit to JuliaIO/ImageMagick.jl that referenced this issue Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant