library(bioimagetools)
## Bioimagetools 1.1.0

Read and write 3D RGB tiff stacks

readTIF() and writeTIF() read and write tiff stacks.

3D and color stacks are automatically recognized by readTIF(), if the meta information is correct. Available meta information is saved as attributes. readTIF() can also handle URLs. The function returns an array with range 0 to 1.

cell <- readTIF("http://ex.volkerschmid.de/cell.tif")
## Warning in tiff::readTIFF(file, all = TRUE, info = TRUE, as.is = as.is, :
## TIFFReadDirectory: Unknown field with tag 50838 (0xc696) encountered
## Warning in tiff::readTIFF(file, all = TRUE, info = TRUE, as.is = as.is, :
## TIFFReadDirectory: Unknown field with tag 50839 (0xc697) encountered
print(dim(cell))
## [1] 512 512   3  52
print(attributes(cell)$dim)
## [1] 512 512   3  52
print(attributes(cell)$bits.per.sample)
## [1] 16
par(pty="s")
img(cell, z=25 ,col="rgb")

plot of chunk readtif

writeTIF() writes out tiff stacks. Meta information in attributes are saved. The bits per sample can be controlled by an option.

writeTIF(cell, file="my_cell.tif")
## [1] 52

readClassTIF() is a special version of readTIF() for images with a very low number of intensity values, e.g. masks or segmented images.

writeTIF(2*EBImage::thresh(cell[,,1,])+EBImage::thresh(cell[,,2,]), file="simple.tif")
## [1] 52
mysimple <- readClassTIF("simple.tif", n=3)
par(pty="s")
img(mysimple[,,25],col="red",up=3)

plot of chunk readclasstif

## [1] TRUE
## [1] TRUE

Plotting

img() is a plotting function for images stored in an array.

par(pty="s")
img(cell, z=25, col="rgb")

plot of chunk img

img(cell, z=25, col="r")

plot of chunk img

img(cell, z=25, col="grey")

plot of chunk img

Reading Bitmap files

Simple Bitmap files can be imported by readBMP().

bi<-readBMP(system.file(package = "bioimagetools","extdata", "V.bmp"))
par(pty="s")
image(bi, col=grey(seq(0,1,length=2^8)))

plot of chunk readMBP