1 Reply Latest reply on Aug 14, 2009 4:20 PM by AIF Bob

Can I use hex in pixel bender code?

Input Image1

Output Pixel4

In the code I am doing manipulation of each byte of a channel.  In the end I end up with:

Pixel1 - Red = 0xFF

Pixel1 - Green = 0xFF

Pixel1 - Blue = 0xFF

Pixel1 - Alpha = 0x00

Pixel2 - Red = 0xFF

Pixel2 - Green = 0xFF

Pixel2 - Blue = 0xFF

Pixel2 - Alpha = 0x00

Pixel3 - Red = 0xFF

Pixel3 - Green = 0xFF

Pixel3 - Blue = 0xFF

Pixel3 - Alpha = 0x00

Pixel4 - Red = 0xFF

Pixel4 - Green = 0xFF

Pixel4 - Blue = 0xFF

Pixel4 - Alpha = 0x00

I am assuming that Pixel Bender doesn't have functions for converting 32byte hex to float, other than internally.  I could implement my own Hex to Float conversion using IEEE 754 as a guide, but that leaves a big hole...namely the special cases (infinity, NaN).

Example:

If I get 55 for each channel (rgb)

Pixel = 0x55555500

I convert to a float using the IEEE 754 standard, and get

Float = 1.4660066e13

Fine...I can output that float as one of the pixels in Pixel4.

But If I get ff for each channel (rgb)

Pixel = 0xffffff00 = %11111111111111111111111100000000

I can't convert to a float because any number that has 255 for the exponent and a non-zero mantissa, means that it's not a number (NaN).

Anything from

%x1111111100000000000000000000001

... to...

%x1111111111111111111111111111111 -> when converting to float comes out as Not A Number.

The only 2 solutions I can see are...

1. I will look for the exponent case 11111111 and change it to something visually similar, but can be converted to float.

2. I need to use a 2^32 lookup table that can sample the pixel 0xFFFFFF00 and output it (which experiments prove it can be done)

Unless hex can be converted to float in pixelbender.

Thanks!

~John

• 1. Re: Can I use hex in pixel bender code?

I don't think I can help you here. All image values in Pixel bender are assumed to be 32 bit floating point - they are converted into that format when you run a Pixel Bender kernel, and the result image is converted from that format afterwards. The conversion functions all assume that they're dealing with valid 32 bit floating point numbers so even if you could find a way to stuff raw byte values into the output imae it's extrenmelt unlikely they would get converted in the way you'd expect.

I don't think that Pixel Bender is the right tool for this particular job.