Entering edit mode
Kent Johnson
▴
10
@kent-johnson-5796
Last seen 10.3 years ago
Hi,
I am using medianFilter from EBImage 4.0.0 in R 2.15.2 on Windows 7
and I
have found a few problems when median filtering a grayscale image.
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.
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
Thanks,
Kent
PS I emailed the EMImage maintainer (paug@gene.com) but received no
reply.
[[alternative HTML version deleted]]