Re: [scikit-image] Observed difference between skimage.filters.rank.mean and scipy.signal.convolve2d
On 4 Nov 2017, 3:13 AM +1100, Poughon Victor <Victor.Poughon@cnes.fr>, wrote:
Thank you, that makes sense. Your link does not explain why float images are restricted to [-1; 1] though? So with my data I can't just do:
image = np.array(data.coins(), dtype=np.float)
I guess skimage makes an assumption that images are within a fixed range?
The short version is that it’s there so that roundtrip conversions work. Suppose you convert a float image to a uint8 image. If you don’t assume a range ([0, 1] for most float images), then you essentially have to map the image range, which could be, say, [0.45, 276.928], to the possible values for uint8, [0, 255]. Then when you convert back, what output range do you use? [0, 10^302]? By assuming a range, you can keep conversions between data types consistent, within rounding error. We are aiming to be more flexible about this, by reducing the dependence on range checking wherever it is not strictly necessary. Many functions have a `preserve_range` keyword that allows you to input images in arbitrary ranges, and you’ll get back an image with no rescaling applied to it. If you come across a function that you think should work without range conversions, let us know. Unfortunately, rank filters don’t fall in this category, because they need to be converted to a 12-bit integer range, so the input range must be known. You can use exposure.rescale_intensity to do conversions manually before and after the rank filters. Hope this helps! Juan.
participants (1)
-
Juan Nunez-Iglesias