EBImage: remove objects on the edge of an image.
1
1
Entering edit mode
Kevin ▴ 40
@kevin-5879
Last seen 10.3 years ago
I did not see this listed in the documentation or in some of the great tutorials but I have an image that I need to remove the objects that intersect the edge of the image. Does anyone know a way to do this? Thanks, Kevin [[alternative HTML version deleted]]
• 1.1k views
ADD COMMENT
0
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 4.1 years ago
Heidelberg, Germany
Dear Kevin, thank you for your interest in EBImage! Although there is no ready-to- use function for removing objects at image boundaries you can easily implement one yourself similar to the following example: # ====================================== library(EBImage) x = readImage(system.file(file.path("images","nuclei.tif"), package="EBImage"), all = FALSE) y = thresh(x, w = 20, h = 20, offset = 0.1) objects = bwlabel(y) display(objects) # subset for boundary pixels dims = dim(objects) border = c(objects[1:dims[1],1], objects[1:dims[1],dims[2]], objects[1,1:dims[2]], objects[dims[1],1:dims[2]]) # extract object identifiers at the boundary ids = unique(border[which(border != 0)]) # create a mask containing objects at the boundary boundary = as.vector(objects) boundary[which(!(objects %in% ids))] = 0 boundary = Image(boundary, dims) display(boundary) # create a mask containing all objects that do not intersect the edge of the image inner = as.vector(objects) inner[which(objects %in% ids)] = 0 inner = Image(inner, dims) display(inner) # now you can use the inner mask to apply some function over the inner objects, e.g. compute their intensity range: tapply(x, inner, range) # ====================================== I hope you find this helpful. Best wishes, Andrzej On Tue, Apr 16, 2013 at 8:39 PM, Kevin <kevinjspring@gmail.com> wrote: > I did not see this listed in the documentation or in some of the great > tutorials but I have an image that I need to remove the objects that > intersect the edge of the image. Does anyone know a way to do this? > > Thanks, > > Kevin > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor@r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

Traffic: 953 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6