[BioC] Problems with medianFilter in EBImage 4.0.0

Andrzej Oleś andrzej.oles at gmail.com
Wed Feb 27 15:36:09 CET 2013


Hi Kent,

many thanks for your feedback on EBImage!


On Tue, Feb 26, 2013 at 8:06 PM, Kent Johnson <kent3737 at gmail.com> wrote:

> The first problem is simple to fix - medianFilter() returns its argument
> unchanged because the line
>
>  z = as.Image(.Call("medianFilter", x, size, colorMode(x) +
>             1, cacheSize))
>
> assigns to z which is then not used; changing this to
>
>  x = as.Image(.Call("medianFilter", x, size, colorMode(x) +
>             1, cacheSize))
>
> should fix that.

Thanks for pointing this out! This typo has been already corrected
before in the devel version of EBImage
(http://www.bioconductor.org/packages/devel/bioc/html/EBImage.html).
Please update to version >= 4.1.1 to get rid of this bug.


> The other problem I don't have a fix for - a median value of 0 is returned
> instead as 1. Here is some code that reproduces the problem (using
> medianFilter internals to work around the first problem):
>
> library(EBImage)
>
> d=matrix(runif(10000, 0.1, 0.9), 100)
> d[50:60, 50:60]=0 # Make a region of constant 0
> display(d)
>
> # From EBImage::medianFilter
> x = d*2^16-1
> y = as.Image(.Call("medianFilter", x, 3, colorMode(x) + 1, 512))
> z = (y-1)/2^16
> display(z) # The black region has turned white

Thank you for reporting this. The conversions between the [0,1] range
and the integer range performed by the 'medianFilter' function are
actually wrong. Instead, they should read:
x*(2^16-1) # conversion to integer range
x/(2^16-1) # conversion back to [0,1] range

I've fixed this in the newest devel version. Calling now
'display(medianFilter(d,3))' should give you the expected result. The
updated EBImage 4.1.5 should be available from the BioC website within
24h.

Best,
Andrzej



More information about the Bioconductor mailing list