0
votes

I have an array of byte[] which contains Dicom Images Pixeldata in memory.

I need to interpolate the images as the Z-Spacing is not proportional (ie: -1;-2;-4;-5;-7;-8;-9)

The Z-spacing needs to be adjusted to be equal between the images (-1;-2;-3;-4;-5;-6;-7;-8;-9)

So I basically need to apply this formula:

PixelValue_n = PixelValue_prior_Image + (Z_n - Z_prior_image)*(PixelValue_img+1 - PixelValue_prior_Image) / (Z_img+1 - Z_prior_image)

Is there a better way to interpolate a byte[] array to not convert that to pixel values? Reason being is that I have images that are 8bpp, 16bpp, 24bpp and 32bpp (uncompressed) and also compressed pixel values so I rather deal with byte[]

Thanks,

Matias

1
Can you tell me which lib you are using to read the images?TaW

1 Answers

1
votes

If your data consists of pixels representing unsigned values, than theres no problem - you can interpolate byte for byte (i.e. 16 bpp: x((a_1 << 8) + a_2) + y((b_1 << 8) + b_2) == ((xa_1 + yb_1) << 8) + (xa_2 + yb_2).

However if they are ment to be signed, your data consists of two's complement codes of the values. Then you could try something freeky like remembering the sign for each %2 (for 16bpp) group of pixels, but only if you want to have some fun.