From ripley at stats.ox.ac.uk  Mon Jul 24 15:22:32 2006
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Mon, 24 Jul 2006 14:22:32 +0100 (BST)
Subject: [Rd] png() and image()
In-Reply-To: <44C4C0EF.2010404@cimr.cam.ac.uk>
References: <59d7961d0607201855x37b2fb3bw6d89939e1409287d@mail.gmail.com>		<44C08042.5070807@ebi.ac.uk>	<59d7961d0607210935i26eb297apf0e4e5981ebb4902@mail.gmail.com>
	<44C4B3D0.7000000@ebi.ac.uk> <44C4C0EF.2010404@cimr.cam.ac.uk>
Message-ID: <1037.195.205.11.116.1153747352.squirrel@webmail.stats.ox.ac.uk>


> Wolfgang Huber wrote:
>> Henrik Bengtsson wrote:
>>> Hi Wolfgang,
>>>
>>> thanks for this - I took a look the EBImage webpage
>>> [http://www.ebi.ac.uk/~osklyar/projects/EBImage/] and it looks very
>>> nice.  Are there any plans for Windows support too?  I am looking for
>>> a cross-platform solution.
>>>
>>> Cheers
>>
>>
>> Hi Henrik,
>>
>> there are very strong intentions to also make this available as a
>> Windows precompiled package and/or provide installation instruction for
>> Windows. Until now however, in spite of some effort, we have failed.
>>
>> As I understand it, a problem seems to be different dll formats of  MS
>> Visual C++ (in which ImageMagick is provided) and MinGW.

There are no such things: the Windows DLL format is one DLL format, and R
uses VC6-compiled DLLs for Tcl/Tk and iconv, for example.  And other
packages (e.g. RNetCDF, rgdal) take the same route.

The issues are usually to use the correct header files that mark entry
points as stdcall rather than cdecl as needed, and to link directly to
the DLL rather than via a VCC-specific import library (which may often
work, but equally often gets the linkage wrong.

>> If anyone is interested in helping with this, they could have a look at
>> the source package on Bioconductor, and contact us for details.
>
> It is probably easier to port ImageMagick to MinGW than to try to
> link mingw-compiled EBImage against MSVC++ compiled imagemagick.

That would run contrary to most experience with Windows porting.

> (Imagemagick does run under cygwin, I believe, so it is not
> entirely hostile to gcc on windows).
>
> HTL
>
>>
>>  Best wishes
>>  Wolfgang
>>
>>
>>
>>> On 7/21/06, Wolfgang Huber <huber at ebi.ac.uk> wrote:
>>>> Hi Henrik,
>>>> this does not directly answer your question, but you might be able to
>>>> use the function write.image in the package EBImage (Bioconductor) to
>>>> write matrices into image files (e.g. PNG or JPEG), this might be more
>>>> flexible and also faster than what you're trying to do.
>>>>   Best wishes
>>>>   Wolfgang
>>>> ------------------------------------------------------------------
>>>> Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber
>>>>
>>>> Henrik Bengtsson wrote:
>>>>> Hi,
>>>>>
>>>>> I try to create PNG images of a certain size where each pixel
>>>>> intensity corresponds to exactly one probe signal in an Affymetrix
>>>>> array.  I try to use png() and image() with zero margins to do this.
>>>>> Example:
>>>>>
>>>>> z <- matrix(1:15, nrow=45, ncol=30)
>>>>> png("large.png", height=nrow(z), width=ncol(z), bg="red")
>>>>> par(mar=c(0,0,0,0))
>>>>> image(z, col=gray.colors(16), axes=FALSE)
>>>>> dev.off()
>>>>>
>>>>> z <- matrix(1:15, nrow=5, ncol=3)
>>>>> png("tiny.png", height=nrow(z), width=ncol(z), bg="red")
>>>>> par(mar=c(0,0,0,0))
>>>>> image(z, col=gray.colors(16), axes=FALSE)
>>>>> dev.off()
>>>>>
>>>>> The problem is that on WinXP the very bottom row and the very right
>>>>> column of pixels in red.  Trying on Linux, it is only the very right
>>>>> column that is red.  See attached images (you might have to zoom in
>>>>> to
>>>>> see it).  I try to do this in R v2.3.1.  The same effect is seen if
>>>>> the jpeg() device is used.
>>>>>
>>>>> When rescaling, the same effect is seen (the red border effect is one
>>>>> pixel wide), e.g.
>>>>>
>>>>> z <- matrix(1:15, nrow=45, ncol=30)
>>>>> png("large5.png", height=5*nrow(z), width=5*ncol(z), bg="red")
>>>>> par(mar=c(0,0,0,0))
>>>>> image(z, col=gray.colors(16), axes=FALSE)
>>>>> dev.off()
>>>>>
>>>>> I might be asking for something that is not supported, but is there a
>>>>> way around this?  It is a problem, because I wish to tile the images
>>>>> in an HTML page.
>>>>>
>>>>> Thanks
>>>>>
>>>>> Henrik
>>>>>
>>
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] png() and image()
ripley at stats.ox.ac.uk