From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vignette effect

Solved!
Go to solution

@Hawk_se wrote:

This is the solution what i needed... There is only one thing left, multiplying this 2D array with flat grayscale image.


Multiplying two 2D arrays of equal size is trivial. No need for loops.

 

Well, the center should be derived from the dimension. they are not independent. You don't need "A", because without it, the max is exactly one, i.e. what you need.

 

Your sigma controls (and their scaling) need to be before the loop. It is expensive to re-read the controls with every iteration of the loop, and if it would get changed during loop execution, all bets are off. (unlikely here, because the loop is so fast!). Carefully check your wiring. You seem to mix CenterX with SigmaY and vice versa. Confusing and probably not right.

 

As I showed above, you can eliminate a lot of complexity by using arrays.

 

Another simple method would be to just create two 1D gaussians and then do the outer product to create the 2D array. Now you only have N+M exponentiations instead of MxN, but the outer product is of course not entirely free. Worth thinking about if your arrays are gigantic, but not here. (some duplicate code can still be eliminated, e.g. the Sqrt(2), not shown)

 

altenbach_0-1617735265349.png

 

0 Kudos
Message 11 of 13
(394 Views)

Multiplying two 2D arrays of equal size is trivial. No need for loops.

     - I'll consider this...

Well, the center should be derived from the dimension. they are not independent. You don't need "A", because without it, the max is exactly one, i.e. what you need.

     - In real applications, center can be shifted from optical axis that's why i need to define this coordinate for my case. But for A parameter you're right.

Your sigma controls (and their scaling) need to be before the loop. It is expensive to re-read the controls with every iteration of the loop, and if it would get changed during loop execution, all bets are off. (unlikely here, because the loop is so fast!)

     - I agree with you, i should define sigma constants before loop!

 

Thank you for your all effort, i'll consider all suggestions and re-design the solution.

0 Kudos
Message 12 of 13
(383 Views)

OK, I made a quick draft during breakfast. (Using an 8 bit image of a Corona Virus found on the internet). You simply need to adapt it for 16bit greyscale (which plain LabVIEW does not support. I don't have the vision toolkit installed).

 

Some suggestions (not implemented):

 

  • It might be easier to have controls for "1/sigma" instead. This way 0 mean "no vignette". Currently you would need to set the sigma=Inf for that. With controls proportional to 1/Sigma, A larger value would mean a larger effect. More intuitive.
  • I would probably implement an event structure so things only recalculate when controls change.
  • Note that the array controls are currently sorted Y,X You can easily modify.
  • etc.

 

altenbach_0-1617810959409.png

 

 

Message 13 of 13
(356 Views)