EBImage crop failure
1
0
Entering edit mode
Gregoire Pau ▴ 310
@gregoire-pau-3274
Last seen 9.6 years ago
Hello Michael, EBImage represents images as multidimensional arrays. Color images are usually represented as 3-dimensional ones, where the third dimension contains the color components. >From your example, it seems that are you are manipulating 3-dimensional arrays, explaining why "a[1:120,50:120]" fails. Use "a[1:120,50:120,]" instead to crop images. Is the image you are working with is a grayscale one ? In this case, you are maybe manipulating an image that was stored as a color one, explaining your array has 3 dimensions. Doing "a = Image(a[,,1], color=Grayscale)" will fix this. Hope this helps, Cheers, Greg --- Gregoire Pau EMBL Research officer http://www.embl.de/~gpau/ On 28/08/2011 15:22, Michael Cole wrote: > Using the latest version of EBImage and ver 8:6.6.9.7-5 of ImageMagick (debian > package) several EBImage operations fail. > > In particular, cropping an image with: > a<-readImage("xxxxxxxx") > a[1:120,50:120] # fails with "incorrect number of dimensions"] > > I can get cropped images by doing: > a[1:120,50:120,1] # display gives correct region with a red mask > a[1:120,50:120,c(1,0,0)] # display gives correct region with a red mask > a[1:120,50:120,c(1,0,1)] # display gives correct region with a yellow mask > a[1:120,50:120,c(1,1,1)] # display gives correct region as grayscale > a[1:120,50:120,c(0,1,1)] # display gives correct region with a yellow mask > > and so on. > > Has there been a change in EBImage that is not reflected in the documentation? > > I am trying to build histograms for each color channel to build classification > models. > > > Thanks, > > Michael > > _______________________________________________ > 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
EBImage EBImage • 1.1k views
ADD COMMENT
0
Entering edit mode
Michael Cole ▴ 20
@michael-cole-4824
Last seen 9.6 years ago
Thanks Gregoire, The images are color. Can I assume img[1:200, 1:200,x] gives a cropped image in red,blue,green where x={1,2,3}? Michael On Fri, Sep 2, 2011 at 3:10 AM, Gregoire Pau <gregoire.pau at="" embl.de=""> wrote: > Hello Michael, > > EBImage represents images as multidimensional arrays. Color images are > usually represented as 3-dimensional ones, where the third dimension > contains the color components. > > From your example, it seems that are you are manipulating 3-dimensional > arrays, explaining why "a[1:120,50:120]" fails. Use "a[1:120,50:120,]" > instead to crop images. > > Is the image you are working with is a grayscale one ? In this case, you > are maybe manipulating an image that was stored as a color one, > explaining your array has 3 dimensions. Doing "a = Image(a[,,1], > color=Grayscale)" will fix this. > > Hope this helps, > Cheers, > > Greg > --- > Gregoire Pau > EMBL Research officer > http://www.embl.de/~gpau/ > > On 28/08/2011 15:22, Michael Cole wrote: >> Using the latest version of EBImage and ver 8:6.6.9.7-5 of ImageMagick (debian >> package) several EBImage operations fail. >> >> In particular, cropping an image with: >> a<-readImage("xxxxxxxx") >> a[1:120,50:120] # fails with "incorrect number of dimensions"] >> >> I can get cropped images by doing: >> a[1:120,50:120,1] # display gives correct region with a red mask >> a[1:120,50:120,c(1,0,0)] # display gives correct region with a red mask >> a[1:120,50:120,c(1,0,1)] # display gives correct region with a yellow mask >> a[1:120,50:120,c(1,1,1)] # display gives correct region as grayscale >> a[1:120,50:120,c(0,1,1)] # display gives correct region with a yellow mask >> >> and so on. >> >> Has there been a change in EBImage that is not reflected in the documentation? >> >> I am trying to build histograms for each color channel to build classification >> models. >> >> >> Thanks, >> >> Michael >> >> _______________________________________________ >> 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 > -- Michael Cole m.cole at rutgers.edu
ADD COMMENT
0
Entering edit mode
Dear Michael Michael Cole scripsit 09/02/2011 06:22 PM: > Thanks Gregoire, > > The images are color. Can I assume img[1:200, 1:200,x] gives a cropped > image in red,blue,green where x={1,2,3}? Yes. What do you get when you type (a <- readImage("xxxxxxxx")) Wolfgang > Michael > > > On Fri, Sep 2, 2011 at 3:10 AM, Gregoire Pau<gregoire.pau at="" embl.de=""> wrote: >> Hello Michael, >> >> EBImage represents images as multidimensional arrays. Color images are >> usually represented as 3-dimensional ones, where the third dimension >> contains the color components. >> >> From your example, it seems that are you are manipulating 3-dimensional >> arrays, explaining why "a[1:120,50:120]" fails. Use "a[1:120,50:120,]" >> instead to crop images. >> >> Is the image you are working with is a grayscale one ? In this case, you >> are maybe manipulating an image that was stored as a color one, >> explaining your array has 3 dimensions. Doing "a = Image(a[,,1], >> color=Grayscale)" will fix this. >> >> Hope this helps, >> Cheers, >> >> Greg >> --- >> Gregoire Pau >> EMBL Research officer >> http://www.embl.de/~gpau/ >> >> On 28/08/2011 15:22, Michael Cole wrote: >>> Using the latest version of EBImage and ver 8:6.6.9.7-5 of ImageMagick (debian >>> package) several EBImage operations fail. >>> >>> In particular, cropping an image with: >>> a<-readImage("xxxxxxxx") >>> a[1:120,50:120] # fails with "incorrect number of dimensions"] >>> >>> I can get cropped images by doing: >>> a[1:120,50:120,1] # display gives correct region with a red mask >>> a[1:120,50:120,c(1,0,0)] # display gives correct region with a red mask >>> a[1:120,50:120,c(1,0,1)] # display gives correct region with a yellow mask >>> a[1:120,50:120,c(1,1,1)] # display gives correct region as grayscale >>> a[1:120,50:120,c(0,1,1)] # display gives correct region with a yellow mask >>> >>> and so on. >>> >>> Has there been a change in EBImage that is not reflected in the documentation? >>> >>> I am trying to build histograms for each color channel to build classification >>> models. >>> >>> >>> Thanks, >>> >>> Michael >>> >>> _______________________________________________ >>> 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 >> > > > -- Wolfgang Huber EMBL http://www.embl.de/research/units/genome_biology/huber
ADD REPLY

Login before adding your answer.

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