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.
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.
01-21-2021 10:33 AM - edited 01-21-2021 11:05 AM
How to do this ?
source is a matrix of 360*100 it is a image
a=[]
i = 0 while i < len(source): j = 0 while j < len(source[0]): a.append(i,j) j += 1 i += 1
Is this correct?
Solved! Go to Solution.
01-21-2021 10:47 AM - edited 01-21-2021 10:48 AM
Hi gpt,
@gptshubham595 wrote:
How to do this ?
Start a text editor and type that text…
@gptshubham595 wrote:
source is a matrix of 360*100
i = 0 while i < len(source): j = 0 while j < len(source[0]): MY_FUCTION() j += 1 i += 1
What exactly is the problem? What have you tried?
I would use 2 autoindexing FOR loops and a subVI named "MY_FUCTION".
Why do you need 2 loops to call "MY_FUCTION" 36000 times? From your question that function does NOT depend on i or j…
01-21-2021 10:47 AM
In LabVIEW we have "auto-indexing" terminals. If you only feed in a 2D array to a for loop, it will run once for each row. If you feed the row into another for loop, it will run once per element, which would be your columns.
01-21-2021 10:51 AM - edited 01-21-2021 10:52 AM
I have edited my question, I want to add a bilateral filter over this image. I am confused regarding two nested while loop,
I know how to implement single while loop
I have edited My_FUNCTION to a array insert, means I have coded this but I want to put it inside a loop
01-21-2021 10:58 AM - edited 01-21-2021 10:58 AM
Hi gpt,
@gptshubham595 wrote:
I am confused regarding two nested while loop, I know how to implement single while loop
Again: use FOR loops with autoindexing inputs!
Place one FOR loop, then place another FOR loop inside the first one to nest them…
01-21-2021 11:00 AM - edited 01-21-2021 11:04 AM
is this correct showing i and j?
01-21-2021 11:09 AM - edited 01-21-2021 11:13 AM
Did you try to run it to prove it to yourself?
No, you need an auto-indexing tunnel on the array wire going into the inner for loop.
Also, your text code seems incomplete. The syntax doesn't show if the i+=1 is part of the inner while loop or outside of that. By indentation, it seems to be outside the inner while loop. But I don't see any syntax that shows where the steps of the inner while loop end.
01-21-2021 11:19 AM - edited 01-21-2021 11:22 AM
I want a value at that i,j index at every iteration but this return an array
even inside the array, I want COLSxROWS, not ROWSxCOLS
means I tried to test this by myself and with a timer but it is not iterating row with cols but I want to iterate with cols with rows
means I want cols x Rows iteration
1 2 3 4
4 5 6 7
8 9 0 1
1
4
8
then
2
5
9
Yes "i" is outside the inner while loop
01-21-2021 11:24 AM - edited 01-21-2021 11:26 AM
Transpose 2D array before you feed it to your loops.
Also, when you have auto-indexing tunnels, you do not need, and really shouldn't, put a constant on the N terminal of the For Loop.
01-21-2021 11:29 AM
@RavensFan wrote:
Did you try to run it to prove it to yourself?
No, you need an auto-indexing tunnel on the array wire going into the inner for loop.
Also, your text code seems incomplete. The syntax doesn't show if the i+=1 is part of the inner while loop or outside of that. By indentation, it seems to be outside the inner while loop. But I don't see any syntax that shows where the steps of the inner while loop end.
Welcome to Python, where indenting IS your delineation of code blocks.