The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
library(bioimagetools)
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.
<- bioimagetools::readTIF("http://ex.volkerschmid.de/cell.tif")
cell ## 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") bioimagetools
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")
bioimagetools## [1] 52
<- readClassTIF("simple.tif", n=3)
mysimple par(pty="s")
::img(mysimple[,,25],col="red",up=3) bioimagetools
## [1] TRUE
## [1] TRUE
img()
is a plotting function for images stored in an
array.
par(pty="s")
::img(cell, z=25, col="rgb") bioimagetools
::img(cell, z=25, col="r") bioimagetools
::img(cell, z=25, col="grey") bioimagetools
Simple Bitmap files can be imported by readBMP()
.
<-readBMP(system.file(package = "bioimagetools","extdata", "V.bmp"))
bipar(pty="s")
image(bi, col=grey(seq(0,1,length=2^8)))
In order to work with single slices, you would like to select the slice from the array:
<-cell[,,,30] slice30
However, this will result in the wrong dimension. bioimagetools always needs 4d array:
dim(slice30) # only 3d
## [1] 512 512 3
dim(slice30) <- c(dim(slice30), 1)
dim(slice30) # 4d
## [1] 512 512 3 1
img(slice30, z=1, col="rgb")
writeTIF(slice10,paste0("slice30.tif"))
## [1] 1
To read single RGB slices, you can use readTIFF. Make sure to add the option channels=3 for an RGB slice.
<-readTIF("slice30.tif", channels=3)
slice30dim(slice30)
## [1] 272 270 3 1
To stack single slices use abind from the abind package:
for (i in 1:52)writeTIF(cell[,,,i],paste0("slice",i,".tif")) # write slices
<-list()
slicefor (i in 1:52)slice[[i]]<-readTIF(paste0("slice",i,".tif"), channels=3) # read slices
<-slice[[1]] # slice 1
allslicesfor (i in 2:52)allslices<-abind::abind(allslices, slice[[i]]) # stack slices 2 to 52
dim(allslices)
## [1] 512 512 3 52
The attributes will be off for the stacked array, so we need to add them from hand using one of the slices (not the dimension!):
<-attributes(slice[[1]])
attrib<-attrib[names(attrib)!="dim"] # Remove dimension attribute
attribattributes(allslices)<-c(attributes(allslices),attrib)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.