[BioC] EBImage: filtering in the presence of NAs

Wolfgang Huber whuber at embl.de
Sat Mar 9 19:51:12 CET 2013

Dear Arnaud

can you provide an example of what else you would expect to happen?

As far as I can see, a linear filter operation on an image is defined as the convolution of the image with a kernel, and for discrete 2D images both kernel and image are assumed to be functions on Z^2 (Z being the whole numbers); usually they have finite support. Alternative, more general definitions are welcome, and we will be happy to consider them. Are you sure you cannot achieve what you want by setting your non-object pixels to a constant value such as zero?

Also, please consider the erode/dilate functions, these in fact do work gracefully with images that contain NA:

x = readImage(system.file("images", "shapes.png", package="EBImage"))
x[200:360, 140:200] = NA


# 186787   9821 

table(is.na(dilate(x, kern)))
# 187071   9537

table(is.na(erode(x, kern)))

# 187384   9224  

	Best wishes	

Il giorno Mar 8, 2013, alle ore 3:43 PM, Arnaud Duranel <arnaud.duranel.09 at ucl.ac.uk> ha scritto:

> Hello
> None of the EBImage filtering functions seems to work when there are NAs in the image:
> library(EBImage)
> lenac = readImage(system.file("images", "lena-color.png", package="EBImage"))
> lenag<-channel(lenac, 'gray')
> lenag[1:50, ]<-NA
> flo = makeBrush(21, shape='disc', step=FALSE)^2
> flo = flo/sum(flo)
> lenaflo = filter2(lenag, flo)
> display(lenaflo)
> any(!is.na(lenaflo))
> Is there a way to process an image that includes NAs, with some kind of na.rm=TRUE?
> I am working with pictures of irregularly-shaped objects, and the pixels between the picture margins and the object were set to NA using a mask. I want to apply filters to the object itself, not to the whole image. Is there another way to do this?
> Many thanks for your help.
> Best regards
> A. Duranel, UCL Department of Geography
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

More information about the Bioconductor mailing list