Newsgroups: comp.unix.questions,sci.image.processing,comp.lang.c
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!yale!zip.eecs.umich.edu!newsxfer.itd.umich.edu!gatech!EU.net!sun4nl!phcoms4.seri.philips.nl!philce!usenet
From: Jeroen Stessen <stessenj@am.umc.ce.philips.nl>
Subject: Re: how to simulate resolution
Content-Type: text/plain; charset=us-ascii
Message-ID: <DBLtDw.61s@ce.philips.nl>
To: xiaoyi@bmecg.bme.ohio-state.edu
Sender: usenet@ce.philips.nl (USENET News System)
Nntp-Posting-Host: 130.144.128.46
Content-Transfer-Encoding: 7bit
Organization: Philips Sound & Vision - TV-lab Eindhoven
References: <3tu6jp$2ab@charm.magnus.acs.ohio-state.edu>
Mime-Version: 1.0
Date: Wed, 12 Jul 1995 12:58:44 GMT
X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
Lines: 36
Xref: glinda.oz.cs.cmu.edu comp.unix.questions:95406 sci.image.processing:15815 comp.lang.c:146524

xiaoyi@bmecg.bme.ohio-state.edu (Xiaoyi Wu) wrote:
>I need to simulate the effect of different resolution
>in a detector to the Signal-noise-ratio in the reconstruction.
>
>The detector could be 8bits, 12 bits, 24 bits, 32bits. 
>What I am doing now is using float type data for projected 
>data which would be 32bits on SGI. 
>
>The question is, how do I change it so that it can represent
>other resolutions? 
>

Use a bit-wise AND (in c language : &) to zero the lower bits,
e.g. if x is a 32 bits INTEGER number (signed int, NOT float),
and if the full rage of the number is used (-2^31 .. +2^31) then
x & 0xffffff00 has 24 significant bits,
x & 0xffff0000 has 16 bits
x & 0xfff00000 has 12 bits
x & 0xff000000 has  8 bits
x & 0xfe000000 has  7 bits
x & 0xfc000000 has  6 bits
x & 0xf8000000 has  5 bits
x & 0xf0000000 has  4 bits
Of course, you keep the most significant part (incl. sign-bit) and
discard the least significant part of your data.

If you must use floating point numbers, say x is between 0.0 and 
1.0, then you can use the floor function to round down,
eg.   floor (x * 4096.0)/4096.0   has 12 bits (unsigned) resolution.
This method costs more in terms of calculation, I prefer the other.

Good luck,
Jeroen Stessen,  Philips TV-lab Eindhoven NL
<stessenj@am.umc.ce.philips.nl>


