05-23-2015 03:17 PM
I have 2d array of data - it is already 'normalised' - everything i divided by max value and then multiplied by 255 - so it gives me 0-255 values in table. What should I do to get grayscale image as output? I already tried sth with FlattenPixmap and DrawFlatenedPixmap but it give me black or gray uniform pixture with different size. I tried it with rounding and some examples i found on the Internet but it does not give me satifying solution.
Any sugesstions?
05-23-2015 07:31 PM
05-24-2015 02:56 AM - edited 05-24-2015 02:56 AM
There is a code and input data I use. It brings me just white picture.
PS The data is the linear fit of phasegram for thermograms obtained via FFT. I want to detect the defect using pulse phase therography.
05-24-2015 08:34 AM - edited 05-24-2015 08:44 AM
Start by taking the absolute value of your array first. Right now you are dividing by the largest value. Since your numbers are negative, that means the value that is closest to zero. Dividing everything else by that means all your other values get to be greater than 1 after normalizing.
Second, your values are all pretty close to each other. So once I normalize them, they all windup being about 225.xxxx and look like they are the same color. You probably want to stretch the smallest to the largest between 0 and 255. Not just 0 to themselves between 0 and 255.
1. Absolute value.
2. Find smallest value.
3. Subtract from Array.
4. Find largest value.
5. Array divided by that times 255.
Once I do those steps, I get something meaningful.

05-24-2015 09:55 AM
Thanks for the response! i should have think it out sooner! silly mistakes.
The image I get is rotated by 90 degrees is it possible to get it without rotation?
05-24-2015 10:32 AM
thor91 wrote:The image I get is rotated by 90 degrees is it possible to get it without rotation?
Yes.
05-24-2015 11:21 AM - edited 05-24-2015 11:23 AM
I had found this link also, and posted a message on it. But that message isn't showing up.
https://decibel.ni.com/content/docs/DOC-2283
EDIT: I found it. It posted in a different message that I wasn't even trying to reply to.
05-24-2015 11:47 AM
@RavensFan wrote:
I had found this link also, and posted a message on it.
That's a different link, though. Mine is more universal. 😄
05-24-2015 12:17 PM - edited 05-24-2015 12:28 PM
Here's about the same with less math.
(Well, it is not the same, because this one scales the grayscale from lowest to highest, while Ravens version inverts the greyscale because it operates on absolute values of a negative array.Taking the absolute value seems dangerous if there is a possibility that the input contains both positive and negative values, for examples. What to use depends what the data means. To get Ravens result in the current case, we could just reverse the color ramp.)

05-25-2015 08:39 AM
I like this tweak to the greyscale creation.
/Y