######################################## # 2014-04-08 # # Matrix operations in R # an image example # NOTE: use matrix_image to show the # correct image plot of a data matrix # with rows and columns in a consistent # order ######################################## # use myfunctions to load an image rm(list=ls()) par(mfrow=c(1,1)) source("scripts/myfunctions.R") M<-loadppm("data/labrador.ppm") p<-seq(1,255,1)/255 p<-(p)^0.5 palette<-gray(p) res<-dim(M) nrow<-res[1] ncol<-res[2] print(paste("size of the n by m matrix: ",nrow," x ",ncol,sep='')) # the matrix_image function returns the buffer (matrix) # usedfor plotting the image buffer<-matrix_image(M,col=palette,main="2-d matrix of brightness intensities") #filled.contour(x,y,M,col=palette)