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

Scaling and Artifact Problem in colorview #204

Open
johnnychen94 opened this issue Jul 4, 2021 · 0 comments
Open

Scaling and Artifact Problem in colorview #204

johnnychen94 opened this issue Jul 4, 2021 · 0 comments
Labels

Comments

@johnnychen94
Copy link
Member

Manually transfered from JuliaImages/Images.jl#882. The following contents are originally posted by @roflmaostc. This seems only an ImageMagick issue, using PNGFiles/ImageIO work arounds it.


Hey,

I observed a bug for which I didn't find an explanation so far. I wrote a Poisson noise function which adds noise to the image. If I inspect the final images with imshow, all seems to be fine.

However, only for the parameter value nphot=3, nphot=5 and nphot=15, if I save the image (or inspect them directly with colorview) these images are scaled and shifted to the left. On the right part, there are some artifacts

I cropped the images so that only intensities between 0 and 1 are possible.

Not working: nphot=3, nphot=5, nphot=15

One working example: nphot=10

Here is the full code example:

using Images, TestImages, PoissonRandom, ImageView

function my_poisson(img; nphot=100)
    nphot = float(nphot)
    max_intens = maximum(img)
    #scale image to maximum number of photons and apply poisson noise
    img_noisy = map(x -> pois_rand(x / max_intens * nphot), img)
    #rescale to initial intensity
    img_noisy = img_noisy ./ nphot .* max_intens

    #crop intensity
    img_noisy = map(x -> max(0.0, x), img_noisy)
    img_noisy = map(x -> min(1.0, x), img_noisy)

    return img_noisy
end


img = testimage("cameraman")

#i=3, i=5 and i=15 cause strange output
for i=1:15
    img_poiss = my_poisson(img, nphot=i)
    img_poiss_view = colorview(Gray, img_poiss)
    save(string("test", i, ".png"), img_poiss_view)
end

#this part works totally fine
img_poiss = my_poisson(img, nphot=15)
img_poiss_view = colorview(Gray, img_poiss)

imshow(img_poiss_view)

Edit: with different image size, the parameter, where the result is weird, changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant