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.
06-03-2020 12:19 PM - edited 06-03-2020 12:22 PM
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:
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
Solved! Go to Solution.
06-03-2020 12:39 PM - edited 06-03-2020 12:40 PM
Can you explain the insert point calculation? All you probably need is "replace array subset" as follows (after calculating the insert points)
(Also I seriously doubt that your code should have anything orange. All calculations are on integers)
06-03-2020 01:19 PM
06-03-2020 02:08 PM
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 🙂
06-03-2020 03:10 PM
@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.
I also include a little tester to verify correct operation.