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: 

Selective copy from 2D array to another 2D array

Solved!
Go to solution

Hi everyone,

Hope you are all doing well

 

I am currently struggling on a bit code that I cannot get to work properly. I have two 2D arrays (typically, pixel values from two images taken from two cameras, not always the same) and I want to copy the pixel value from the first array (let's call it Array Src) to the second array (Array Dst) - effectively replacing Dst's values with Src ones. However, they are two difficulties here: (1) Src and Dst does not always have the same size, (2) Src can be bigger than Dst, but it can also be smaller. As a matter of fact, the final size will always be the one of Dst, regardless if Src is bigger, equal in size, or smaller than Dst. If Src is smaller than Dst, the value from Dst should be kept but most importantly Src should be centered then on Dst.

 

I tried to make the VI code I attached to the message, and I also copy a screenshot here:

Capture.PNG

 

The code itself terminates without an error, but the problem is that all the values inserted into Dst are exactly the same, despite Src having lots of different value. I tried to locate the issue and edit the variable types especially for the indices, but it still does not work properly (there is some left overs of these attempts in the picture and VI I attached).
Also, I have the feeling that my code is perhaps too complicated for what I am trying to do, but this is just a feeling...

 

If someone tried to do something similar in the past, of if you could have a look at the code to help me with this issue, that would be awesome.

 

Thank you in advance for the help, and I hope I was clear enough in the description of the situation


Best

Vivien

0 Kudos
Message 1 of 5
(2,429 Views)

Can you explain the insert point calculation? All you probably need is "replace array subset" as follows (after calculating the insert points)

 

altenbach_0-1591205880803.png

 

(Also I seriously doubt that your code should have anything orange. All calculations are on integers)

 

0 Kudos
Message 2 of 5
(2,417 Views)
Solution
Accepted by topic author VWalter

OK, after further study, this should get you close to what you want.

 

altenbach_0-1591208319977.png

 

Message 3 of 5
(2,394 Views)

Hi altenbach. Thank you for the really swift reply!

 

After your first post I modified my code to insert your suggestions - which of course worked perfectly and solved my problem - and I was about to submit it when you replied. And your code is definitively way simpler than mine!

 

So thank you a lot for the help 🙂

0 Kudos
Message 4 of 5
(2,371 Views)

@VWalter wrote:

And your code is definitively way simpler than mine!


Actually it was still a little complicated. We don't need anything green or coercion dots.

 

altenbach_0-1591214709993.png

 

I also include a little tester to verify correct operation.

 

altenbach_1-1591214904626.png

 

 

0 Kudos
Message 5 of 5
(2,359 Views)