# How does ContourDetect work for arrays?

By the Wolfram Documentation, ContourDetect gives a binary sparse array in which 1 corresponds to zeros and zero crossings in an array. However, in the example:

In[7]:= ContourDetect[{4, 0, 1, -2, 1, -2, -3, -1, 3}] // Normal
Out[7]= {0, 1, 1, 0, 1, 0, 0, 0, 1}


Why -2 at position 4 and 6 corresponds to 0s? Didn't we cross zero by going from 1 to -2? What makes a number in an array a zero crossing?

• ListPlot[{#, ContourDetect[#] // Normal}, Joined -> True] &@{4, 0, 1, -2, 1, -2, -3, -1, 3} as well as with other lists suggests, that 0 is always replaced with 1. Apart from that, any pair of adjacent numbers {..., a, b, ...}, where a b is strictly negative, is subject to a replacement where the negative number becomes a zero, and the positive - a one. Jun 8, 2016 at 15:43
• What about ContourDetect[{4, 0, 1, -2, 1, -2, -3, -1, 3}, 2] for example? Does it find the places where the the array of points cross 2? Jun 9, 2016 at 22:05
• No, what led you to think that way? That's equivalent to ContourDetect[Chop[N@list, 2]] Jun 9, 2016 at 22:13