[BioC] EBImage: alpha plane in grey scale

Samuel GRANJEAUD - IR/ICIM granjeau at tagc.univ-mrs.fr
Mon Feb 28 17:46:14 CET 2011


Hello Gregoire,

Good news, you got the answer.

Thanks a lot,
Samuel

Gregoire Pau wrote:
> Hello Samuel,
>
> Running the following code on my system:
> > library("EBImage")
> > a = matrix(runif(20*20), 20, 20)
> > writeImage(a, "a.tiff")
> > system("tiffinfo a.tiff")
>
> Gives me:
> Image Width: 20 Image Length: 20
>   Resolution: 72, 72 pixels/inch
>   Bits/Sample: 16
>   Compression Scheme: None
>   Photometric Interpretation: min-is-black
>   FillOrder: msb-to-lsb
>   Orientation: row 0 top, col 0 lhs
>   Samples/Pixel: 1
>   Rows/Strip: 204
>   Planar Configuration: single image plane
>   Page Number: 0-1
>   DocumentName: a.tiff
>   Software: ImageMagick 6.5.7-8 2010-12-02 Q16
>
> Only one sample per pixel is present here. I am using EBImage 3.7.1 
> and ImageMagick 6.5.7. It seems that your version of ImageMagick is 
> very old and is likely the cause of the extra alpha layer. I guess 
> updating it will solve your problem.
>
> Hope this helps,
>
> Best,
>
> Greg
> ---
> Gregoire Pau
> EMBL Research Officer
> http://www.embl.de/~gpau/
>
> On 28/02/11 14:35, Samuel GRANJEAUD - IR/ICIM wrote:
>> Hello,
>>
>> Sometimes we build examples that do not reflect our minds. Sorry I was
>> wrong in putting the same value in the matrix. Nevertheless, the runif
>> matrix leads to the same result in respect to my point. As tiffinfo
>> enlights it, there is an extra plane (aka ExtraSamples) in the tiff,
>> that leads to a SamplePerPixel value of 2. Now BitsPerSample are 16 of
>> course.
>>
>> Best regards.
>>
>>  > library(EBImage)
>> Loading required package: abind
>>  > a = matrix(runif(20*20), 20, 20)
>>  > writeImage(a, "a.tiff")
>>  > system("tiffinfo a.tiff")
>> TIFF Directory at offset 0x648 (1608)
>> Image Width: 20 Image Length: 20
>> Resolution: 72, 72 pixels/inch
>> Bits/Sample: 16
>> Compression Scheme: None
>> Photometric Interpretation: min-is-black
>> Extra Samples: 1<unassoc-alpha>
>> FillOrder: msb-to-lsb
>> Orientation: row 0 top, col 0 lhs
>> Samples/Pixel: 2
>> Rows/Strip: 102
>> Planar Configuration: single image plane
>> DocumentName: a.tiff
>> Software: ImageMagick 6.3.7 12/02/10 Q16 http://www.imagemagick.org
>>
>>
>> Gregoire Pau wrote:
>>> Hello Samuel,
>>>
>>> EBImage uses ImageMagick's WriteImage() to write images and doesn't do
>>> anything more. Image format is guessed by ImageMagick from the file
>>> name and the dynamic range of the image. As an example, the following
>>> code creates a random uniform 16-bit grayscale TIFF 20x20 image:
>>> > library("EBImage")
>>> > a = matrix(runif(20*20), 20, 20)
>>> > display(a)
>>> > writeImage(a, "a.tiff")
>>>
>>> Your example uses an image with only one color and ImageMagick (and
>>> therefore EBImage) uses the 1-bit mode of the TIFF image format to
>>> write it. The bug you are facing seems to come from the fact that
>>> ImageJ does not support the 1-bit TIFF image format.
>>>
>>> In the future, it would be nice to have more control in the output
>>> image format. But, in the meanwhile, just use more colors to force
>>> EBImage to use the 16-bit format.
>>>
>>> Hope this helps,
>>> Best regards,
>>>
>>> Greg
>>> ---
>>> Gregoire Pau
>>> EMBL Research officer
>>> http://www.embl.de/~gpau/
>>>
>>> On 25/02/2011 19:37, Samuel GRANJEAUD - IR/ICIM wrote:
>>>> Hello,
>>>>
>>>> I am using EBImage to convert matrix to tiff grey scale. And I would
>>>> like to read them directly in ImageJ. Unfortunately such image 
>>>> contains
>>>> an extra plane that is not needed and not supported by ImageJ. This
>>>> alpha plane seems to be automatically added at the creation of the 
>>>> image
>>>> in the C code (I guess). In ImageMagick API, this is referred as 
>>>> "matte"
>>>> http://www.imagemagick.org/api/magick-image.php#MagickSetImageMatte
>>>>
>>>> If I am not wrong, it would be nice if this alpha plane could be 
>>>> removed
>>>> in next release.
>>>>
>>>> Regards,
>>>> Samuel
>>>>
>>>> ~$ R --vanilla
>>>>
>>>> R version 2.12.1 (2010-12-16)
>>>> Copyright (C) 2010 The R Foundation for Statistical Computing
>>>> ISBN 3-900051-07-0
>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>
>>>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>>>> You are welcome to redistribute it under certain conditions.
>>>> Type 'license()' or 'licence()' for distribution details.
>>>>
>>>> Natural language support but running in an English locale
>>>>
>>>> R is a collaborative project with many contributors.
>>>> Type 'contributors()' for more information and
>>>> 'citation()' on how to cite R or R packages in publications.
>>>>
>>>> Type 'demo()' for some demos, 'help()' for on-line help, or
>>>> 'help.start()' for an HTML browser interface to help.
>>>> Type 'q()' to quit R.
>>>>
>>>> > library(EBImage)
>>>> Loading required package: abind
>>>> > a <- matrix(10,20,20)
>>>> > b <- Image(a)
>>>> > b
>>>> Image
>>>> colormode: Grayscale
>>>> storage.mode: double
>>>> dim: 20 20
>>>> nb.total.frames: 1
>>>> nb.render.frames: 1
>>>>
>>>> imageData(object)[1:5,1:6]:
>>>> [,1] [,2] [,3] [,4] [,5] [,6]
>>>> [1,] 10 10 10 10 10 10
>>>> [2,] 10 10 10 10 10 10
>>>> [3,] 10 10 10 10 10 10
>>>> [4,] 10 10 10 10 10 10
>>>> [5,] 10 10 10 10 10 10
>>>>
>>>> > writeImage(b,"b.tif")
>>>> > system("tiffinfo b.tif")
>>>> TIFF Directory at offset 0x6c (108)
>>>> Image Width: 20 Image Length: 20
>>>> Resolution: 72, 72 pixels/inch
>>>> Bits/Sample: 1
>>>> Compression Scheme: None
>>>> Photometric Interpretation: min-is-black
>>>> Extra Samples: 1<unassoc-alpha>
>>>> FillOrder: msb-to-lsb
>>>> Orientation: row 0 top, col 0 lhs
>>>> Samples/Pixel: 2
>>>> Rows/Strip: 1638
>>>> Planar Configuration: single image plane
>>>> DocumentName: b.tif
>>>> Software: ImageMagick 6.3.7 12/02/10 Q16 http://www.imagemagick.org
>>>> > system("convert b.tif +matte c.tif")
>>>> > system("tiffinfo c.tif")
>>>> TIFF Directory at offset 0x44 (68)
>>>> Image Width: 20 Image Length: 20
>>>> Resolution: 72, 72 pixels/inch
>>>> Bits/Sample: 1
>>>> Compression Scheme: None
>>>> Photometric Interpretation: min-is-black
>>>> FillOrder: msb-to-lsb
>>>> Orientation: row 0 top, col 0 lhs
>>>> Samples/Pixel: 1
>>>> Rows/Strip: 2730
>>>> Planar Configuration: single image plane
>>>> DocumentName: c.tif
>>>> Software: ImageMagick 6.3.7 12/02/10 Q16 http://www.imagemagick.org
>>>> > sessionInfo()
>>>> R version 2.12.1 (2010-12-16)
>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>
>>>> locale:
>>>> [1] LC_CTYPE=en_GB.utf8 LC_NUMERIC=C [3] LC_TIME=en_GB.utf8
>>>> LC_COLLATE=en_GB.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_GB.utf8 [7]
>>>> LC_PAPER=en_GB.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11]
>>>> LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C
>>>> attached base packages:
>>>> [1] stats graphics grDevices utils datasets methods base
>>>> other attached packages:
>>>> [1] EBImage_3.6.0 abind_1.1-0
>>>>
>>>> _______________________________________________
>>>> 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