computing segment areas on an image after thresholding
1
0
Entering edit mode
Guest User ★ 13k
@guest-user-4897
Last seen 9.6 years ago
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.
EBImage EBImage • 1.4k views
ADD COMMENT
0
Entering edit mode
@henrik-failmezger-4201
Last seen 9.6 years ago
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.
ADD COMMENT
0
Entering edit mode
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]]
ADD REPLY
0
Entering edit mode
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 hist(img[,,1]) Hope this helps, Wolfgang > > > > ________________________________ 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 Wolfgang Huber EMBL http://www.embl.de/research/units/genome_biology/huber
ADD REPLY

Login before adding your answer.

Traffic: 560 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