Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest way to display raster image in R?

Tags:

r

I'm working with TIFF images in R. I load images as

library(tiff)
img <- readTIFF("someimage.tiff")

I'm manipulating with img array then and want to see the results. One of the options is use writeTIFF function to store the image on the disk and open it with an image viewer. However I wish to have some simple way to display images inside R. What would you recommend?

like image 374
avli Avatar asked Aug 07 '15 07:08

avli


People also ask

How do I view raster in R?

Raster files are most easily read in to R with the raster() function from the raster package. You simply pass in the filename (including the extension) of the raster as the first argument, x .

What is a raster object in R?

An object of class "raster" is a matrix of colour values as given by rgb representing a bitmap image. It is not expected that the user will need to call these functions directly; functions to render bitmap images in graphics packages will make use of the as.

How do I create a raster image?

Select all layers of the image under the Layers palette and click under the toolbar to 'rasterize' the layers. Select the height and width pixels to determine the final image size. Adjust the resolution and color mode to align with your final desired product.


1 Answers

here's one option:

img <- readTIFF(system.file("img", "Rlogo.tiff", package="tiff"))
grid::grid.raster(img)
like image 101
baptiste Avatar answered Oct 21 '22 04:10

baptiste