07-03-2013 02:09 AM
I need to count the number of elements that are between 0 and 255 from a matrix.
I have attached my code but I don't know how to pass the count from the inner loop to the outer loop.
Can you help me with this? If there is a way to do this without loops, even better.
Thank you
Solved! Go to Solution.
07-03-2013 02:29 AM - edited 07-03-2013 02:30 AM
Hi slov,
did you check the comparison functions palette? Did you notice the "InRangeAndCoerce" function?
(For large arrays with more than 32k "elements in range" you will need one extra step...
To answer your question:
Move that "0" constant outside the outer loop and the wiring will be much easier...
07-03-2013 03:25 AM
Thank you. Haha didn't expect the reply this fast. I would have given you another one for the promptness.
Hmm the maximum value I can get is 863168 so I'm guessing I need to use an extra step but I didn't understand where.
But I am getting some weird values though. Even negatives which should not be happening.
Any ideas why?
07-03-2013 03:59 AM
If you're getting negatives i guess the U8 is overflowing? Add an U8 to I32 before the sum array.
/Y
07-03-2013 07:19 AM
The negative numbers problem seems to be resolved thank you but still gives unexpected values. ANything to do with the array size being 1920000?
07-03-2013 09:40 AM
07-03-2013 12:11 PM
@slovintern wrote:
The negative numbers problem seems to be resolved thank you but still gives unexpected values. ANything to do with the array size being 1920000?
As Gerd mention above, if array is bigger than 32k, you need 1 more step.
/Y
07-04-2013 02:14 AM
I'm sorry but I didn't understand what the extra step is
07-04-2013 02:17 AM - edited 07-04-2013 02:18 AM
Hi slov,
you didn't follow my question/suggestion from message #6. So how should we know, what you've done so far?
To explain your problem: The Sum function doesn't give the expected result because of an overflow due to an inappropriate datatype. You can check the datatype of a wire by moving the mouse pointer over the wire and looking at the context help. You already have been told how to convert that datatype and you already got a suggestion on which datatype to use...
07-05-2013 07:08 AM
Ah sorry looks fine now. I need to first acquire an image and then create the array from there.
The fault was during the acquisition. When I try it normally it looks fine. But I can't figure out the problem with the acquisition.
Can I ask you guys the question here or should I start a new thread?