-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
imadjustintensity
deprecation suggests adjust_histogram
which gives different results
#894
Comments
Also, how would you feel about making |
Thanks you for raising the issue. If you had been working with grayscale images, then the direct replacement for imadjustintensity(img) would be adjust_histogram(img, LinearStretching(nothing => (0,1)) and so the deprecation message as it currently stands is misleading. The issue boils down to the fact that
So by writing adjust_histogram(img, LinearStretching(nothing => (0,1)) you are saying you want to map The situation is a little more nuanced for RGB images because the convention used in the The julia> img = RGB{Float32}[RGB{Float32}(6.024074f-7,-2.481209f-5,-1.2082533f-5), RGB{Float32}(6.815455f-5,6.5870896f-5,7.189392f-5)]
2-element Array{RGB{Float32},1} with eltype RGB{Float32}:
RGB{Float32}(6.024074f-7,-2.481209f-5,-1.2082533f-5)
RGB{Float32}(6.815455f-5,6.5870896f-5,7.189392f-5)
ls = LinearStretching(extrema(channelview(img)) => nothing);
img2 = copy(img);
map(i -> adjust_histogram!(view(channelview(img2), i, :,:), ls), 1:3);
julia> img2
2-element Array{RGB{Float32},1} with eltype RGB{Float32}:
RGB{Float32}(0.26280162f0,0.0f0,0.1316315f0)
RGB{Float32}(0.9613326f0,0.9377182f0,1.0f0) A "cleaner" way of achieving what you want is with f = takemap(scaleminmax,img)
julia> f.(img)
2-element Array{RGB{Float32},1} with eltype RGB{Float32}:
RGB{Float32}(0.26280165f0,0.0f0,0.1316315f0)
RGB{Float32}(0.9613326f0,0.9377182f0,1.0f0) I noticed that the values of your example RGB image actually contain negative values, whereas normally valid values are supposed to lie within the unit interval. If I understood correctly, you were trying to map these values into a valid range with @timholy Is there any particular reason why we went with |
In simple words, For more complex deprecation that |
I have a dangling issue (JuliaImages/ImageContrastAdjustment.jl#32) related to this functionality. It still bothers me that the 'cleaner' solution for contrast stretching requires multiple steps instead of a self-contained function call. Sorry I haven't found time to make the PR yet! |
I'm working on updating https://github.com/rdeits/EdgeCameras.jl and I noticed a deprecation warning about
imadjustintensity
being replaced withadjust_histogram(img, LinearStretching())
. However, at least for the data I'm working with, those two methods produce very different results.Here's a very simple example:
The new
adjust_histogram
makes the first pixel nearly black and the second white, while the oldimadjustintensity
preserved some of the color information.Is there a way to accurate reproduce the old
imadjustintensity
behavior with the new API? And can we change the deprecation warning to match?The text was updated successfully, but these errors were encountered: