LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2d array into grayscale picture

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?

0 Kudos
Message 1 of 10
(7,090 Views)

Create an U8 array with 256 element greyscale ramp.

 

For example like this or this.

 

If you want more specific advice, show us your code.

0 Kudos
Message 2 of 10
(7,051 Views)

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.

Download All
0 Kudos
Message 3 of 10
(7,023 Views)

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.

 

Message 4 of 10
(6,977 Views)

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?

0 Kudos
Message 5 of 10
(6,966 Views)

thor91 wrote:

The image I get is rotated by 90 degrees is it possible to get it without rotation?


Yes.

0 Kudos
Message 6 of 10
(6,952 Views)

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.

http://forums.ni.com/t5/LabVIEW/how-to-save-data-into-the-excel-sheet-each-time-when-i-run-my-VI/m-p...

0 Kudos
Message 7 of 10
(6,929 Views)

@RavensFan wrote:

I had found this link also, and posted a message on it.


That's a different link, though. Mine is more universal. 😄

Message 8 of 10
(6,916 Views)

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.)

 

0 Kudos
Message 9 of 10
(6,901 Views)

I like this tweak to the greyscale creation.

Greyscale.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 10 of 10
(6,839 Views)