Search
Question: Deals with image value superior to 0,1 range
0
gravatar for valerian.meline
14 months ago by
valerian.meline0 wrote:

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

ADD COMMENTlink modified 13 months ago • written 14 months ago by valerian.meline0
2
gravatar for Andrzej Oleś
14 months ago by
Andrzej Oleś710
Heidelberg, Germany
Andrzej Oleś710 wrote:

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
readImageInt = function(...) {
  y = readImage(...) * max16b
  storage.mode(y) = "integer"
  y
}

identical(x, readImageInt(writeImageInt(x, f)))
## [1] TRUE
ADD COMMENTlink modified 14 months ago • written 14 months ago by Andrzej Oleś710
0
gravatar for valerian.meline
13 months ago by
valerian.meline0 wrote:

Hello Andrzej,

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

Valérian

ADD COMMENTlink written 13 months ago by valerian.meline0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 174 users visited in the last hour