06-24-2021 03:59 AM
Hi,
Working with arrays in LabVIEW is relatively new to me and I'm having some difficulty with (what I'm sure is) a relatively simple function and would really appreciate some help.
I am trying to retrieve a column of pixels from an image and insert them into a larger image starting at a specific co-ordinate. I'm able to extract the array I need, but when I try to insert it using 'Replace Array Sub-set' into a blank array, I'm still getting blank values in the new array.
I've tried to break it down in it's own vi to actually understand what is happening with the arrays and I'm still not getting the result I'd hoped.
Visualisation of what I'm trying to do:
Block diagram:
Front Panel:
Actual application:
Using the IMAQ SetRowCol, I can make it work for the x-axis from the input map, but this puts the extracted column at the top of the image
I tried to change to the use of arrays and I have many failed attempts to get this to work under my belt, e.g:
The input map is a csv, with 3 values, the ID (x-pos in original image), New XPos, New YPos.
The attached 'Arrays Simplified.vi' is my VI I'm trying to understand the arrays with.
The attached 'Array Subset 3.vi' is my actual application, which has the Input Map and test image attached.
If I had any hair left, I'd be pulling it out, any guidance would be massively appreciated. I'm clearly making some kind of schoolboy error.
Thanks,
Aidan
Solved! Go to Solution.
06-24-2021 04:13 AM - edited 06-24-2021 04:15 AM
Hi Aidan,
@Jee_with_a_J wrote:
The attached 'Arrays Simplified.vi' is my VI I'm trying to understand the arrays with.
Your item "3" shows you missed to use shift registers in that loop for the "Blank" array".
@Jee_with_a_J wrote:
The attached 'Array Subset 3.vi' is my actual application, which has the Input Map and test image attached.
Again you missed to use a shift register to hold your array data! In each iteration of the loop you forget about all previous changes…
06-24-2021 08:01 AM
Hi GerdW,
You have no idea how many of your solutions I have used over the past few years, feels like a privilege to finally have some direct input from you!
Okay, so I managed to fix my simplified arrays to make them work as expected - hoorah!
I've now spent the last 2 hours trying all manner of things to get my arrays to work with shift registers in my application but I'm not having any luck. It seems like it's iterating through correctly, but still getting a blank image.
I'd really appreciate it if you can point me in the right direction.
Thanks!
Aidan
06-24-2021 08:58 AM
Hi Aidan,
@Jee_with_a_J wrote:
I've now spent the last 2 hours trying all manner of things to get my arrays to work with shift registers in my application but I'm not having any luck. It seems like it's iterating through correctly, but still getting a blank image.
I don't use IMAQ/Vision functions, so I can only guess:
06-24-2021 09:34 AM
@Jee_with_a_J wrote:Visualisation of what I'm trying to do:
Why do you think you need a FOR loop to replace a rectangular subset with another rectangular subset from a different array?
All you need is ensure that you have a 2D subset (even if it is only one column wide!) and "replace array subset" can do it in one operation. Here is an exact and loop-free solution to the above problem:
Some general advice:
Please resize your array containers of the demo code to show a reasonable amount of elements and keep the upper left index at 0,0. If the array is too large, show the scrollbars. It is very difficult to see what going on if you have a 1x1 container and shif the index to a non-existing element.