Still plodding along with my library to read DICOM files (medical images).
I have a two-dimensional array (rows x columns) of pixel data where each element in the array is a value between x and y (where x = black and y = white). Values between x and y are shades of grey.
I am trying to convert this array into a Picture object. I know I can set the individual colour of a pixel through the Picture.Graphics.Pixel method but what I can’t figure out is how to convert my values (of between 0-1) into grayscale Xojo Colors. Does that make sense??
On a related note, a lot of the files actually seem to have 4096 levels of grey (12 bits) - this is common for CT scans. Is there a way to scale this to RGB?
Hi Garry, you mean to convert that to 8 bit RGB images?
I can’t tell you about the fastest way of doing it in Xojo, but I can try to explain what you are dealing with and how you would convert it manually.
If your images are like mine, you have 12 bit data within a 16 bit file. Since RGB images have three 8 bit channels you need to convert those 12 bits to 8 bits (by dividing by 4 bits).
However, you may need to take into account where the actual data range (those 4096 levels of grey) are within your 16 bit range. In the case of the images I am working with (transmision electron microscopy, similar to CT scans) the actual data are not always in the same range within the 16 bits. So, you first must shift all the grey levels to asign a 0 value to the lowest grey level value present in your image, then divide by those 4 bits.
Would you mind posting a histogram of the grey levels of the image? You can do it using ImageJ, which if you don’t know about I think you should check it. ImageJ allows you to process images and sets of images using macros/scripts too, which may be an option in your case.