[BioC] EBImage crop failure

Gregoire Pau gregoire.pau at embl.de
Fri Sep 2 09:10:40 CEST 2011


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



More information about the Bioconductor mailing list