LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build/ assign value to array elements

Solved!
Go to solution

I have an array of size 600 by 600 pixels. In a circle of given radius (say 50 pixels) and given origin (given ith row and jth column), I want to plot gaussian distribution, i.e., give the pixels

the value of a 2-D gaussian distribution with peak at the origin. How do I do this in labview ?

 

Thanks. 

0 Kudos
Message 1 of 12
(1,240 Views)
Solution
Accepted by topic author Alice12

You would run your x and y values through the 2D Gaussian function but making the origin 300,300 (for your given 600x600 pixel array). Here's what I get on an intensity chart given an amplitude of 10 and sigma = 100 pixels:

 

2D Gaussian.png

 

 

Here's the example (quick and dirty) code:

2DGaussiansnippet.png

Message 2 of 12
(1,221 Views)
Highlighted

--

0 Kudos
Message 3 of 12
(1,201 Views)

 

Thanks for your reply.

How do I convert this intensity distribution into a greyscale (uint8) image (a matrix with all elements between 0 and 255) ?

I used "To Unsigned Byte Integer" function but it doesn't seem to solve the problem ? 

 

0 Kudos
Message 4 of 12
(1,193 Views)

Just change the amplitude on the output of the exponential to 255 (instead of the 10 in my code example) and then convert to U8. Like this (after changing the marker colors in the intensity chart):

 

2DGaussianGray.png

0 Kudos
Message 5 of 12
(1,179 Views)

I tried to follow your hints but didn't succeed. May be I'm missing something silly.

Attached is my program. Please change it to obtain the desired pattern.

 

Thanks.

0 Kudos
Message 6 of 12
(1,157 Views)

You used the wrong exponential...Use "exp(x)" instead of "exp(x) - 1".

0 Kudos
Message 7 of 12
(1,147 Views)

Thank you for pointing out the mistake.

It works.

 

Regards.

0 Kudos
Message 8 of 12
(1,142 Views)

Here's a one-loop version. It is sufficient to calculate a singe 1D gaussan once, then use the outer product to generate the 2D array.

This means we only need to evaluate only 600 exponential functions instead of 360000! Smiley Very Happy (You could reduce it again by 50% taking advantage of symmetry. Try it!)

(see also)

 

 


LabVIEW Champion Do more with less code and in less time
Message 9 of 12
(1,141 Views)

Thanks.

It's definitely a better approach.

 

Regards.

0 Kudos
Message 10 of 12
(1,128 Views)