Hi Im experimenting with mean pixel values for a series of images from a DSLR. I import 16-bit TIFs (RGB) from a directory using the following code, then loop through adding each TIF before dividing by the total number of files to give an image of mean pixel values. Some quick questions: -having checked pixel values, this does what I expect it to do in that it creates the mean for each RGB layer in each image. It is pretty quick, but is a function that calculates both the mean and median pixel values for stacked layers like this? -do all the calculations take place in 32 bit space? The tiff package lets me export as 16 bit tiffs, but is there anything that supports 32 bit tiffs?? -I get the following writeTIFF error (and the number has been scaled from the original 16 bit to 0-1): "The input contains values outside the [0, 1] range - storage of such values is undefined" -is there a more elegant/memory efficient way of doing this?! Any help much appreciated! best wishes mike PS Two sample images here: http://www.hsm.org.uk/1.tif http://www.hsm.org.uk/2.tif #Scan directory and store filenames in string, then count total files files <- as.character(list.files(path="./mean/input/")) n <- length(files) #Use first TIF as loop file, then add all together m_image_tiff <- readTIFF(paste("./mean/input/",files[1],sep="")) for (i in 2:n){ test<-paste("./mean/input/",files[i],sep="") tiff <- readTIFF(paste("./mean/input/",files[i],sep="")) m_image_tiff <- (tiff+m_image_tiff) } #Calculate mean and write TIF m_image_tiff <- (m_image_tiff/n) writeTIFF(m_image_tiff,"./mean/mean_tiff.tif",bits.per.sample=16L) --- Mike Smith