Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

I am creating many grayscale varying imag

es (typically in the forms of sine waves). I have no problems creating the images or displaying them, but I can't find a simple method of saving the double precision array of pixel values I've created as a 16-bit array. Can anyone help?? Thanks, Mark H.
0 Kudos
Message 1 of 5
(3,428 Views)
es (typically in the forms of sine waves). I have no problems creating the images or displaying them, but I can't find a simple method of saving the double precision array of pixel values I've created as a 16-bit array. Can anyone help?? Thanks, Mark H.Mark,

The simplest way to save an image is to use the write image vi's. I assume these will not work for what you are doing.

The next option is to extract the bitmap as a 2-D array, and save the array using the standard file IO vi's. You need to open the file, write the array (set header to TRUE), and close the file. You should be able to read the file in the same way by wiring an empty 2-D array to the read file vi. Then you need to convert the array back to an image.

Let me know if you are still stuck after this.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 5
(3,428 Views)
es (typically in the forms of sine waves). I have no problems creating the images or displaying them, but I can't find a simple method of saving the double precision array of pixel values I've created as a 16-bit array. Can anyone help?? Thanks, Mark H.Thanks for your response, Bruce.
Actually I am creating the image from a 2D array I create, so the array part is already there. However, the 2D array I create contains all double precision values (for example 512x512 double precision values ranging from 0 to 2.) In order to save an 8-bit image I divided 255 (2^8) by the maximum value in the 2D array of doubles, and then multiplied every value of the 2D array by this quotient (scale it). Then I round to the nearest integer and convert to an 8 bit integer. The same process is used for 16 bit with the appropriate 16 bit conversion value. It seems to work.
Do you know of a simpler way, this seems like it would already be in a VI somewhere??
Thanks,
Mark H.
0 Kudos
Message 3 of 5
(3,428 Views)
es (typically in the forms of sine waves). I have no problems creating the images or displaying them, but I can't find a simple method of saving the double precision array of pixel values I've created as a 16-bit array. Can anyone help?? Thanks, Mark H.Mark,

It looks like the IMAQ Cast Image might make it a little easier to convert between numerical formats. I haven't worked extensively with floating point images, so I have never tried saving them. Is it not possible to display and save them directly as floating point images without converting? Another point: most screens can only display 256 shades of gray, so there isn't much point in using 16 bit images.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 5
(3,428 Views)
es (typically in the forms of sine waves). I have no problems creating the images or displaying them, but I can't find a simple method of saving the double precision array of pixel values I've created as a 16-bit array. Can anyone help?? Thanks, Mark H.Bruce,
This IMAQ Cast Image does not convert from floating point to 16-bit in the manner desired, because the values of the image created is between 0 and 2, and when directly converted a step function is the result (rather than including the sloping increase and decrease of a sine wave by using all 8 or 16 bits to represent the sine wave from min to max). The conversion/calculation described in my earlier comment above is necessary in my case before the IMAQ Cast Image would take place.
It is possible to display them directly as floating point images (haven't tried saving them), however, the application I am creating, needs them to be saved in either 8-bit or 16-bit format-- ideally, 16 bit. Without taking too much time to go into detail, we're
performing FFT's on these images, then inverse FFT's, then calculating modulation depth--with 16 bits there will be higher resolution and greater accuracy in our measurements. This calculation, and not for display purposes, is the reason for 16 bits.
Thanks for the feedback.

Mark
0 Kudos
Message 5 of 5
(3,427 Views)