<div dir="ltr">Hi All,<div> I am new to python and image processing in general.</div><div> I am having trouble working with 12 bit images to do some very simple calculations. Here is some example code:</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><p style="font-size: 11px; font-family: Menlo;">#!/usr/local/bin/ipython</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">#import Imaging Library</p>
<p style="font-size: 11px; font-family: Menlo;">from PIL import Image</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">from skimage import io, filters</p>
<p style="font-size: 11px; font-family: Menlo;">from skimage import img_as_float</p>
<p style="font-size: 11px; font-family: Menlo;">from skimage import exposure</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">#import pylab for plotting</p>
<p style="font-size: 11px; font-family: Menlo;">from pylab import *</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">Aim = io.imread("A.tiff")</p>
<p style="font-size: 11px; font-family: Menlo;">Bim = io.imread("B.tiff")</p>
<p style="font-size: 11px; font-family: Menlo;">Cim = io.imread("C.tiff")</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">Dim = Aim - Cim</p>
<p style="font-size: 11px; font-family: Menlo; min-height: 13px;"><br></p>
<p style="font-size: 11px; font-family: Menlo;">Eim = Bim - Cim</p></blockquote><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p style="font-size: 11px; font-family: Menlo;">#print min and max values of the background subtracted images</p>
<p style="font-size: 11px; font-family: Menlo;">print("min %d max %d" % (Aim.min(),Aim.max()))</p></blockquote><div> <span style="font-family: Menlo; font-size: 11px;">print("min %d max %d" % (Bim.min(),Bim.max()))</span> </div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p style="font-size: 11px; font-family: Menlo;">print("min %d max %d" % (Dim.min(),Dim.max()))</p>
<p style="font-size: 11px; font-family: Menlo;">print("min %d max %d" % (Eim.min(),Eim.max()))</p></blockquote><div><br></div><div> Input images A,B and C are 12 bit greyscale TIFFs.</div><div> Output:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><p style="font-size: 11px; font-family: Menlo;">min 0 max 4095</p></div></blockquote><div> <span style="font-family: Menlo; font-size: 11px;">min 0 max 4095</span> </div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>
<p style="font-size: 11px; font-family: Menlo;">min 0 max 65533</p>
<p style="font-size: 11px; font-family: Menlo;">min 0 max 65533</p></div></blockquote><div> The input image data response to min and max make good 12bit sense, but it is totally beyond me how I am getting 16bit responses for D and E.</div><div> I want to understand what's happening here so that I don't get bitten when I try to do transformations that require me to use floating point math. </div><div><br></div><div>thanks,</div><div>Johnny</div></div>