- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create an image of matrix of pixels in R?
A matrix can be converted into a pixel’s image of matrix. It is defined as the area of the matrix which contains pixels with equal or different sizes of left, right, bottom and upper.
We can create this by using image function and its argument useRaster with the matrix data.
Example
> M<-matrix(rnorm(100,1.5),nrow=10) > par(mar=c(5,5,5,5)) > image(M,useRaster=TRUE,axes=FALSE)
Output
> par(mar=c(10,10,10,10)) > image(M,useRaster=TRUE,axes=FALSE)
Output
> par(mar=c(2,2,2,2)) > image(M,useRaster=TRUE,axes=FALSE)
Output
Pixel matrix with grey color −
> image(M,axes=FALSE,col=grey(seq(0,1,length=180)))
Output
Advertisements