akash-akya / vix

Elixir extension for libvips
MIT License
171 stars 20 forks source link

Unexpected result of vips_hist_local #119

Closed kipcole9 closed 1 year ago

kipcole9 commented 1 year ago

Environment

Elixir: 1.14, 1.15 OTP: 25, 26 vips: vips-8.14.2

Current behaviour

I'm implementing local contrast (CLAHE via vips_hist_local). The discussion topic references an image of Jupiter (copied here for convenience): jupiter Running the example from the discussion:

vips hist_local ~/pics/bigjupio.jpg vips.jpg 100 100 --max-slope 70

returns the image per the example: j2 But if I call the operation directly the results are very different:

iex> i = Image.open! "/Users/kip/Desktop/jupiter.jpg"
%Vix.Vips.Image{ref: #Reference<0.1349829312.3253862428.149286>}
iex> Vix.Vips.Operation.hist_local!(i, 100, 100, max_slope: 70) |> p

jupiter_local_contrast

Expected result

The result of the vips command at the Vix.Vips.Operation.hist_local/4 are the same. I note that Vix.Vips.Operation.hist_equal/2 does not seem to have the same issue.

akash-akya commented 1 year ago

@kipcole9 the vix is using the prebuilt nif right? Just want to make sure it is not due to the use different libraries.

akash-akya commented 1 year ago

@kipcole9 just checked the doc, the option should be "max-slope": I think (not max_slope:). Can you try that?

I can see that it can be confusing, maybe we can raise error on invalid param name, or accept param names with underscore instead of -

kipcole9 commented 1 year ago

@akash-akya , my sincere apologies. That was the issue. I'm sure I checked that since it's the common format for vips but I messed up. Sorry for the fire drill.