Deals with image value superior to 0,1 range
2
0
Entering edit mode
@valerianmeline-12890
Last seen 4.3 years ago

Hello,

I use EBImage to analyse chlorophyll fluorescence images. The pixels values are contains between 0 and 1500. I can read these images but I can't write them while keeping the fluorescence values.

I can't export them with the intensity contrast  (0,1 range) because I need to keep these chlorophylll fluorescence range values.

Do you know how can i write these images without rescaling between 0 and 1 ?

Cheers,
Valérian

value ebimage writeImage error • 592 views
2
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 8 months ago
Heidelberg, Germany

Dear Valérian,

you can save your images as 16 bit TIFFs and transform between the integer and double pixel representation on read/write. For this when saving your images you would divide the pixel values by the maximum value which can be stored as unsigned integer (UINT16), which is 2^16-1.  To transform the data back to integer range after loading the image multiply it by  2^16-1. The resulting image will contain integer values but stored internally as doubles, so in order to obtain output identical to your original data you want to change the storage mode back to "integer".  For convenient use it's probably a good idea to define some wrapper functions, say writeImageInt and readImageInt.

library(EBImage)

max16b = 2^16-1

# test image containing integer values
x = Image(1:max16b, c(2^8, 2^8))

f = "tmp.tiff"

# scale to double 0:1 range on write
writeImageInt = function(x, ...) {
writeImage(x/max16b, ...)
}

# rescale to integers on read
storage.mode(y) = "integer"
y
}

## [1] TRUE
0
Entering edit mode
@valerianmeline-12890
Last seen 4.3 years ago

Hello Andrzej,

Perfect it works for my data, Thank you very much for you fast answer

Valérian