05-15-2020 10:48 PM - edited 05-15-2020 11:33 PM
So I am dealing with an image (jpg), I converted that image into a 2D array. I would like to be able to take every other index of that array and store it in a new 2D array. I've tried to look at many examples but many focus on 1D array. This is what I did, not getting anything when I try to run it. I'm pretty new in labview so much help would be appreciated.
05-15-2020 11:31 PM - edited 05-15-2020 11:45 PM
A lot of code makes no sense, for example why would you reshape to a 2D array with 1 row. If you want to keep every other row, you need to keep it a 2D array. Now just autoindex on a single FOR loop and conditionally index every odd or even row.
05-15-2020 11:47 PM
Here;s one possibility to take all odd indices (odd rows, odd columns, i.e. 4x fewer elements).
05-15-2020 11:48 PM - edited 05-15-2020 11:49 PM
Just wanted to clarify, like this? I've attached the updated VI too, apologies for the beginning.
05-15-2020 11:57 PM
So that constant 1 on the outside determines whether it's every odd element or even element? So, I could put a 2 there to get every even element? As long as the value doesn't equal 0 then to decimate that index and insert it to the new array? Just want to make sure I understand.
05-16-2020 01:05 AM - edited 05-16-2020 01:07 AM
@TheNameIsBailey wrote:
So that constant 1 on the outside determines whether it's every odd element or even element? So, I could put a 2 there to get every even element? As long as the value doesn't equal 0 then to decimate that index and insert it to the new array? Just want to make sure I understand.
No, its always a 1. Basically we are masking off the lowest bit, so the result is zero or one. If the result is zero, we have an even number and if it is not zero, we have an odd number.
Of course you can stick to your Q&R, it's just more computational effort but is more scalable if you e.g. later need code to take every third row.
05-16-2020 01:39 AM
oh so to make it get every even we just need to change the command to "=0" instead?