[BioC] EBImage crop failure

Michael Cole m.cole at rutgers.edu
Fri Sep 2 18:22:10 CEST 2011


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



More information about the Bioconductor mailing list