02-01-2013 07:53 AM
Hello Folks,
I want to make an application, which can seperate each pixel row of a Image and reassemble them again as two pictures , one with odd rows and another with even pixel rows.
I have made a block diagram to seperate individual rows in an Image. For that I have read an imge convert into matrix and then using two 'for' loops I am seperating the each row. But after reading all the rows VI is not comming to end. it goes on repeating. Can anyone please figureout why it goes on repeatedly ?
Any ideas how to reassemble them again as odd rows together and even rows together ??
Regards
Neo
02-01-2013 08:02 AM - edited 02-01-2013 08:03 AM
You have a while loop with a stop button. If you don't press the stop button, the while loop will just keep repeating. What did you want?
BTW, your code can be simplified quite a bit by using AutoIndexing on the input array.
02-01-2013 08:14 AM
Hello Crossrulz,
I just want the program to read the image only once, not until I press stop button. when the for loops read last pixel value in image it should stop.
If I use auto indexing How can I read each row seperately??
My main application here is seperate each rows of image and reassemble them odd rows as one image and even rows as other Image.so,I want to get out each individual row as output and give it as input to some other block to reassemble them as odd rows as one image and even rows as other Image . Please correct me if my approach is wrong for this problem.
Regards
Neo
02-01-2013 08:30 AM
Neo6 wrote:
I just want the program to read the image only once, not until I press stop button. when the for loops read last pixel value in image it should stop.
I have not looked at your program, so my comments may be irrelevant.
There are lots of IF statements below... 😉
If the snippet above is put inside a WHile Loop, it will probably keep on repeating itself until, as mentionned, you click on the STOP button.
If you placed it inside a While Loop with the intent of having the application execute until you are done and want to exit, but you only want the image to be loaded once, then you need to have the appropriate structure.
If the snippet above and the While Loop are part of your main GUI, then the structure you need is an Event Structure. Well... not quite that simple.
If the above is true, then you should use the template under the File menu > New...
Then select From Template and look for "Producer/Consumer Design Pattern (Events).
Your existing code would go into the bottom While Loop within the Case Statement indexed by the appropriate event (usually typeDef enum).
The top loop would take care of the user / operator (and other) events. Such as pressing the stop or exit button.
There are thousands of examples in this forum.
02-01-2013 08:58 AM
Neo6 wrote:
If I use auto indexing How can I read each row seperately??
When you autoindex a 2D array, they are indexed out as rows
02-01-2013 09:42 AM
Hello Crosrulz, Ray.R
@Crossrulz
Thnx for the tip. It simplified my block diagram.
@Ray.R
Producer consumer design is also in my consideration. But I think above snippet will go to the top structure( which is producing Image rows) and reassembling into two images will go to the bottom structure (which consumes and reassemble into two Images) .
what you guys think ??? Do I need to use Queue for preventing loss of data ??
Regards
Neo
02-01-2013 10:24 AM
If going to a producer/consumer, I was definately recommend queues.
02-01-2013 10:27 AM
Producer / consumer in the way I described it are for user / operator events, which are the types of events being produced. The consumer loop handles the events. You can use a Notifier unless you plan to do many actions at once (while the consumer loop operates), then a queue would be needed. But typically, a notifer does the trick (imagine a single element queue).
The reason for proposing that is to allow the application to continue running, but the code which does the image handling will only run once.
As I said, I did not look at your code yet, so I do not have a full image of what you are doing (I pop in & out of the forum as I grab something to drink). Are you doing some image capture at the same time as you would like to see what you are capturing? If so, then yes, you could have another producer/consumer loop... Or.. well.. let's not get into complicated things just yet 😉
02-01-2013 11:10 AM - edited 02-01-2013 11:11 AM
To split the 2D array into two 2D arrays, one with the odd and one with the even rows, you could do something as follows.
(I assume we have an even number of rows, and that the first row (row zero) is even. If you want a different definition, just modify accordingly)