LinearStretching() can not do imadjustintensity(..., (minval,maxval))
bjarthur opened this issue · comments
the args to imadjustintensity
specify the "from" range, whereas those of the same name to LinearStretching
are the "to" range. are there plans to add this functionality to the new API before the old is deprecated? my sole use case is imadjustintensity(img, quantile(img,[0.01,0.99]))
, which i find quite good at eliminating outliers when adjusting the brightness.
great to finally get rid of the "im" prefix! thanks for that!
This is an oversight on my behalf. Until you pointed it out, I actually didn't notice that imadjustintensity
was using the "from" range. We should absolutely add this functionality. I'm not sure how to best proceed to avoid breaking the current ImageContrastAdjustment
API, and what the cleanest design might look like.
One straightforward option is to add another keyword, e.g.
LinearStretching <: AbstractHistogramAdjustmentAlgorithm
LinearStretching(; from = true, minval = 0, maxval = 1)
that determine the direction of the transformation.
However, this approach doesn't solve the case when someone may want to adjust both the source and target range. Therefore, maybe we should implement the most generic version of linear stretching, where one can specify both the source and target intervals. On the other hand, the most generic version might be "inconvenient" as it may become longer to type when specifying all the ranges. @timholy @johnnychen94 Do you have any suggestions?
+1 on the most generic version where both the "from" and "to" range can be specified.
wouldn't be inconvenient if sensible defaults were used. like extrema(img)
for the "from" and (0,1) for the "to".
How about using Pair
?
LinearStretching(img::AbstractArray{T};
values = extrema(img) => (gamutmin(T), gamutmax(T))) where T <: Colorant
values
doesn't sound a good name to me, I was thinking the keyword name range
but it's used in Base
. Perhaps valuemap
?
how would one specify just the "from" or "to" with a Pair like that?
also, LinearStretching
does not input an image, so the explicitly calculating a default like that will not work.