[BioC] computing segment areas on an image after thresholding

Wolfgang Huber whuber at embl.de
Sat Aug 4 00:25:02 CEST 2012

Dear Ravi

Aug/3/12 10:16 PM, ravi scripsit::
> Hi Henrik, Thanks a lot for your reply. Your code works like a charm.
> I would like to follow up with the following questions : 1. You say
> that I should choose the image[,,1]. That's fine. I would like to
> know more about the structure of the image data. What does each of
> image[,,i] for i=1 ..4 consist of?

This is a series of 4 images of DAPI-stained nuclei, taken from 
different regions of a single well in a 384-well plate. In general, the 
third dimension of an "Image" object is intended to be used for such 
additional dimensions (beyond x, y), which can be e.g.:
   - z-axis
   - time
   - different experimental factors
or a combination of all of these. From the help page of "Image":
The 'colormode' slot could be either 'Grayscale' or 'Color'. In
both modes, the two first dimensions of the underlying array are
understood to be the spatial dimensions of the image. In the
'Grayscale' mode, the remaining dimensions contain other images.
In the the 'Color' mode, the third dimension contains the red,
green and blue channels of the image and the remaining dimensions
contain other images.

> 2. How can I get a histogram of the intensity values in the image.
> Something equivalent to imhist in matlab. Thanks, Ravi


Hope this helps,

> ________________________________ From: Henrik Failmezger
> <henrik.failmezger at googlemail.com> To: Ravi [guest]
> <guest at bioconductor.org>
> ger at cip.ifi.lmu.de> Sent: Friday, 3 August 2012, 21:28 Subject: Re:
> computing segment areas on an image after thresholding
> Hi Ravi,
> you can do that by:
> img = readImage(system.file("images", "nuclei.tif",
> package="EBImage"))[,,1] imgB=createBinaryImage(img) imgB=!imgB #flip
> foreground to background imgS=bwlabel(imgB)
> fShape=computeFeatures.shape(imgS)
> you have to flip the background of the binary image, as bwlabel
> considers pixel with value 0 as background, whereas
> createBinaryImage converts dark objects on a light background to
> foreground.
> You can get the area of the nuclei by:Â  fShape[,"s.area"]
> Cheers, Henrik
> 2012/8/3 Ravi [guest] <guest at bioconductor.org>:
>> Hi, I would like to develop a method for meassuring the percent
>> area of a certain phase in an image. I have looked at packages
>> EBImage and CRImage. But I am not able to make much headway. My
>> code looks like this : library(EBImage) library(CRImage) img =
>> readImage(system.file("images", "nuclei.tif",
>> package="EBImage"))[,,1] #x = thresh(img, 10, 10, 0.05) #x =
>> opening(img, makeBrush(5, shape=’disc’)) #x = bwlabel(x)
>> imgG=EBImage::channel(img,"gray") t=calculateOtsu(as.vector(imgG))
>> imB<-createBinaryImage(imgG,threshold=t) fts =
>> computeFeatures.shape(i1[,,1])
>> computeFeatures.shape seems to require a 2D array. But even the
>> binary image has a dim 0f 510*510*4. I would like to have help with
>> the following questions : 1. From any general image, how do I
>> create a binary image after using different thresholding criteria
>> (to start with, the otsu method). 2. Sum all the segment areas
>> corresponding to the phase of interest and then get the percent
>> area. 3. I would like to have some help in interpreting the results
>> of the last command (computeFeatures.shape) when I vary the third
>> dimension from 1 to 4. The s.area results are different. What does
>> this mean? How does one get a binary image without this variation?
>> Thanks, Ravi
>> Â  -- output of sessionInfo():
>> R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386
>> (32-bit)
>> locale: [1] LC_COLLATE=Swedish_Sweden.1252Â
>> LC_CTYPE=Swedish_Sweden.1252Â  Â  LC_MONETARY=Swedish_Sweden.1252
>> [4] LC_NUMERIC=CÂ  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> LC_TIME=Swedish_Sweden.1252
>> attached base packages: [1] splines   stats     graphicsÂ
>> grDevices utils     datasets  methods   base
>> other attached packages: Â  [1] CRImage_1.6.0Â  Â  Â  aCGH_1.34.0Â
>> Â  Â  Â  multtest_2.12.0Â  Â  Biobase_2.16.0Â  Â
>> BiocGenerics_0.2.0 survival_2.36-14 Â  [7] cluster_1.14.2Â  Â
>> DNAcopy_1.30.0Â  Â   EBImage_3.12.0Â  Â   abind_1.4-0
>> loaded via a namespace (and not attached): [1] class_7.3-4Â  Â
>> codetools_0.2-8 e1071_1.6Â  Â  Â   foreach_1.4.0Â   iterators_1.0.6
>> MASS_7.3-19Â  Â   stats4_2.15.1 [8] tools_2.15.1
>> -- Sent via the guest posting facility at bioconductor.org.
> [[alternative HTML version deleted]]
> _______________________________________________ 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

Best wishes

Wolfgang Huber

More information about the Bioconductor mailing list