How to add a constant value to pixels below zero
jhargis wrote on Feb 19, 2007
All -
I'm sure this is a relatively simple question. I would like to know how to implement the following on my images:
If any pixel value on the images is less than zero, then add constant value (say 65,535 for example).
Thanks,
Jonathan Hargis
(The real problem is that for some reason my images, when exposed to more than 32,000 counts start to become negative in number. So I have to add 65,000 counts to get the true number of counts.)
I'm sure this is a relatively simple question. I would like to know how to implement the following on my images:
If any pixel value on the images is less than zero, then add constant value (say 65,535 for example).
Thanks,
Jonathan Hargis
(The real problem is that for some reason my images, when exposed to more than 32,000 counts start to become negative in number. So I have to add 65,000 counts to get the true number of counts.)
Mike Fitzpatrick wrote on Feb 19, 2007
Comes up a lot with unsigned short integers, the trick is
You can use the CHPIXTYPE task to change the pixel type of images as well.
Cheers,
-Mike
cl> imexpr "(a < 0 ? a+65536 : a)" outimg a=inimgYou can use the CHPIXTYPE task to change the pixel type of images as well.
Cheers,
-Mike
jhargis wrote on Feb 19, 2007
Mike,
Thanks for the fix!
Is there a recommended way to deal with this problem? Should I add the 65,536 to the pixels, and then convert to "real" via CHPIXTYPE for example?
- Jonathan
Thanks for the fix!
Is there a recommended way to deal with this problem? Should I add the 65,536 to the pixels, and then convert to "real" via CHPIXTYPE for example?
- Jonathan
Mike Fitzpatrick wrote on Feb 19, 2007
It depends because sometimes the problem is that it's a "bad" FITS file, e.g. BITPIX=16 is supposed to be a signed short integer, some software writes this as an unsigned short. IRAF follows the FITS standard and so the values are read as signed, in this case add the offset with IMEXPR.
-Mike
-Mike
Last post on Feb 19, 2007