One possible approach would be to use a sequence of: thrust::transform - to convert the input data to all 1 or 0: 0 27 42 0 18 99 94 91 0 -- input data 0 1 1 0 1 1 1 1 0 -- this will be our "mask vector"...

c#,vector,coordinates,cudafy.net

After a bit of searching I found Bresenham's line algorithm which was more or less just what I needed. Please refer to this answer if you're interested in the algorithm I used....

c#,.net,timing,stopwatch,cudafy.net

As the TotalMilliseconds is constantly incrementing & you are trying to find differences between points in time, you need to subtract the sum of the preceding differences after the second one, hence : tIQR = watch.Elapsed.TotalMillisconds - (tHistogram + tHistogramSum); & tThresholdOnly= watch.Elapsed.TotalMillisconds - (tHistogram + tHistogramSum + tIQR); ...