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? 

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



________________________________
 From: Henrik Failmezger <henrik.failmezger@googlemail.com>
To: Ravi [guest] <guest@bioconductor.org> 

ger@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@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]]

