NERSCPowering Scientific Discovery Since 1974

R Examples

 

Reading Images

Load package ripa:

> library(ripa)

Read a jpeg image:

> img <- readJPEG('/global/scratch2/sd/youname/cells.jpg')

Read a png image:

> img <- readPNG('/global/scratch2/sd/youname/'cells.png)

Visualize jpeg and png images:

> plot(imagematrix(img))

 

View from command line View from RIPA interface
 

 Read and visualize LAN (Landsat) images:

> lan_img <- read.lan('/global/scratch2/sd/youname/rio.lan')

> plot(imagematrix(lan_img))

 

View from command line View from RIPA interface

 Read and visualize AVIRIS images:

> num_bands = c(50,60,78,90,145) #choose indexes of bands to be read

> bands = vector(length=length(num_bands),mode="list")

> aviris_img <- read.aviris('/global/scratch2/sd/youname/avimage.a',num_bands,bands,0) # the last parameter indicates run in

# parallel or not (0 or 1)

> plot(imagematrix(aviris_img))

 

View from command line View from RIPA interface

 

 

 

 

 

Choose samples (bands indexes):

 

 After reading:

 

Checking Image Attributes

The code below shows how to get general attributes from an image:

> dim(aviris_img)

[1] 512 614 41

> mode(aviris_img)

[1] "numeric"

> summary(aviris_img) # for all the image bands

Min. 1st Qu. Median Mean 3rd Qu. Max.

0.00000 0.04241 0.10460 0.11410 0.17050 1.00000

> summary(as.vector(aviris_img[,,30])) # for band 30

Min. 1st Qu. Median Mean 3rd Qu. Max.

0.00000 0.02688 0.13830 0.13030 0.20590 1.00000

> typeof(aviris_img)

[1] "double"

 

Exploring other image attibutes from RIPA:

Viewing information about one image band

 

Bands Brushplot
 

 


Enhancing image properties with filters