Obama made out of letters

Per the request of @M_T_Patterson and @statsByLopez

The code to generate the following image is below.  Enjoy.

barryO


library(EBImage)
set.seed(1234)
#im<-readImage("/Users/gregorymatthews/Dropbox/Rart/queenOfHearts.jpeg")
#im<-readImage("/Users/gregorymatthews/Desktop/IMG_9074.jpg")
#im <- readImage("/Users/gregorymatthews/Desktop/guyAlley.jpg")
im <- readImage("/Users/gregorymatthews/Desktop/barry.png")
ddd<-dim(im)
gran<-50
xxx<-round(seq(1,ddd[1],length=gran))
yyy<-round(seq(1,ddd[2],length=gran))
small<-im@.Data[xxx,yyy,]
ddd<-dim(small)

png("/Users/gregorymatthews/barryO.png",h=13,w=19,unit="in",res=100)
plot(0,0,frame.plot=F,xlim=c(0,ddd[1]),ylim=c(0,ddd[2]),col="white",asp=1,xaxt='n',yaxt='n',xlab="",ylab="")

for (i in 1:ddd[1]){print(i)
                    for (j in 1:ddd[2]){
                                        points(i,ddd[2]-j,col=rgb(small[i,j,1],small[i,j,2],small[i,j,3],alpha=0.5),pch=sample(c("O","B","A","M"),1),cex=runif(1,0.5,7))
                    }
}

dev.off()

Cheers.

Advertisements

Posted on June 3, 2014, in R. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: