[R] size of a pixmap image

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 7 20:26:50 CEST 2003


On 7 Aug 2003, Tito de Morais Luis wrote:

> Dear listers,
> 
> I loaded a pixmap image with:
> brobo <- read.pnm("brobo.pnm")
> 
> I can have the characteristics of the image with:
> > brobo
> Pixmap image
>   Type          : pixmapRGB
>   Size          : 609x682
>   Resolution    : 1x1
>   Bounding box  : 0 0 682 609
> 
> How can I retrieve the image size ?
> nrow(brobo) and ncol(brobo) give NULL

> getClass("pixmap")

Slots:
                                      
Name:     size cellres    bbox  bbcent
Class: integer numeric numeric logical

Known Subclasses: "pixmapChannels", "pixmapIndexed", "pixmapGrey", 
"pixmapRGB"

brobo at size, to get the equivalent of dim(), nrow is brobo at size[1], ncol 
brobo at size[2], or:

setGeneric("nrow", function(x) standardGeneric("nrow"))
setMethod("nrow", "pixmap", function(x) { x at size[1] })

gets you there.

Roger

> 
> I succeeded using:
> 
> > nrow(getChannels(brobo))
> [1] 609
> > ncol(getChannels(brobo))
> [1] 682
> 
> It looks a bit tricky, is there another way ?
> 
> Thanks in advance,
> 
> Tito
> 
> Running Mandrake 9.1
> 
> > version
>          _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    1
> minor    7.1
> year     2003
> month    06
> day      16
> language R
> 
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list