LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO DRAW THIS VI:NESTED WHILE LOOP

Solved!
Go to solution

I've been doing C and javascript lately where curly braces for code blocks and semicolons for end of command rule the day.

 

Knowing how hard it is to get indentation right on code editors, I'd be scared that code will suddenly change.

But having an environment where appearance on screen and code structure are linked seems like a good idea.

 

 

0 Kudos
Message 11 of 16
(114 Views)

 

    Wp = 0
    i = 0
    while i < 5:
        j = 0
        while j < 5:
            w = i * j
            Wp = Wp+w
            j += 1
        i += 1
i_f= 10 + Wp

I want to add and store values and use them outside the loop.

0 Kudos
Message 12 of 16
(135 Views)

Seems like your garden variety nested For Loop problem. Where are you stuck?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 13 of 16
(131 Views)

 

gptshubham595_1-1611258321959.png

 

 

My main intention is this PYTHON CODE

Re: How to apply bilateral filter - NI Community

 

def apply_bilateral_filter(source, filtered_image, x, y, diameter, sigma_i, sigma_s):
    hl = diameter/2
    i_filtered = 0
    Wp = 0
    i = 0
    while i < diameter:
        j = 0
        while j < diameter:
            neighbour_x = x - (hl - i)
            neighbour_y = y - (hl - j)
            if neighbour_x >= 360:
                neighbour_x -= 360
            if neighbour_y >= 360:
                neighbour_y -= 360
            gi = gaussian(source[neighbour_x][neighbour_y] - source[x][y], sigma_i)
            gs = gaussian(distance(neighbour_x, neighbour_y, x, y), sigma_s)
            w = gi * gs
            i_filtered += source[neighbour_x][neighbour_y] * w 
            Wp += w  // *************STUCK AT HERE**********///
            j += 1
        i += 1
    i_filtered = i_filtered / Wp
    filtered_image[x][y] = int(round(i_filtered))

 

0 Kudos
Message 14 of 16
(125 Views)
Solution
Accepted by topic author gptshubham595

Well, that code is quite "spaghettified" but somewhere or another, you're going to need a shift register to keep track of i_filtered. You'll only need two loops also, not four. This is the solution to your original post, see if it gives you some ideas.

Spoiler
loop.png

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 15 of 16
(110 Views)

If you are not familiar with loops and shift registers, I would recommend you learn more about LabVIEW from here. How to Learn LV

Message 16 of 16
(101 Views)