Sliding window over a 2D vector, implementation of Marching Squares algorithm I have not used C++ in quite a while and looking for advice/feedback, the code below implements the Marching Squares Algorithm which is detailed here.
While the implementation appears correct and gives the same result as the example on the Wikipedia page, I think that some of the code could be improved and I'm looking for general feedback on how.
In particular,


how I handle vectors
the 2x2 sliding matrix that moves across the test data
where I OR in a value




#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;tchar.h&gt;
#include &lt;vector&gt;
using std::vector;


void ApplyThreshold(vector&lt;vector&lt;int&gt;&gt; &amp;Matrix2D, int threshold);
vector&lt;vector&lt;int&gt;&gt; CreateContourMatrix(vector&lt;vector&lt;int&gt;&gt; &amp;pMatrix);

int main()
{

    const int cutOff = 2;//The value on which to base the creation of contours
    vector&lt;vector&lt;int&gt;&gt; matrix;
    //Setup test data
    matrix.push_back(vector&lt;int&gt; { 1, 1, 1, 1, 1 });
    matrix.push_back(vector&lt;int&gt; {1, 2, 3, 2, 1, });
    matrix.push_back(vector&lt;int&gt; {1, 3, 3, 3, 1, });
    matrix.push_back(vector&lt;int&gt; {1, 2, 3, 2, 1, });
    matrix.push_back(vector&lt;int&gt; {1, 1, 1, 1, 1, });

    vector&lt;vector&lt;int&gt;&gt; pMatrix = matrix;

    ApplyThreshold(pMatrix, cutOff);//Establishthe contours
    auto contourMatrix = CreateContourMatrix(pMatrix);//Build contour shapes
    //Print the result
    for (auto contour_row : contourMatrix)
    {
        for (int element : contour_row)
        {
            std::cout &lt;&lt; element &lt;&lt; '\t';
        }
        std::cout &lt;&lt; std::endl;
    }
    return 0;
}
/*
 * Move a 2x2 window across a 2d matrix, calculating contour shapes
 */
vector&lt;vector&lt;int&gt;&gt; CreateContourMatrix(vector&lt;vector&lt;int&gt;&gt; &amp;pMatrix)
{
    vector&lt;vector&lt;int&gt;&gt; contourMatrix;
    //vector&lt;int&gt; rows[5];
    for (int i =0;i&lt;pMatrix.size() - 1;i++)
    {
        vector&lt;int&gt; row;//Should this allocation be moved out of the for loop?

        for (int j=0;j&lt;pMatrix[0].size() - 1;j++)//Assume that all rows of the image are the same size
        {
            int shape = 0;
            if (pMatrix[i][j] == 1)
                shape = shape | 8;
            if (pMatrix[i][j + 1] == 1)
                shape = shape | 4;
            if (pMatrix[i+1][j] == 1)
                shape = shape | 1;
            if (pMatrix[i+1][j+1] == 1)
                shape = shape | 2;
            row.push_back(shape);
        }
        contourMatrix.push_back(row);
    }
    return contourMatrix;
}

void ApplyThreshold(vector&lt;vector&lt;int&gt;&gt; &amp;Matrix2D, int threshhold)
{
    for (auto rowVector : Matrix2D)
    {
        for (auto vectorValue : rowVector)
        {
            if (vectorValue &gt;= threshhold)
                vectorValue = 1;
            else
                vectorValue = 0;
        }
    }
}


This isn't supposed to be a complete implementation, i.e. I don't deal with ambiguous cases or actually create an image of the contours. Any advice appreciated.
A couple miscellaneous things. 

I don't think you need the vector&lt;int&gt; for the initialization. eg:

matrix.push_back({ 1, 1, 1, 1, 1, });


You can use references in the for loops, just for good measure. IMO using the type instead of auto makes it easier to read when it's a simple type too.

for (auto&amp; contour_row : contourMatrix)
{
    for (int&amp; element : contour_row)
    {
        std::cout &lt;&lt; element &lt;&lt; '\t';
    }
    std::cout &lt;&lt; std::endl;
}


In CreateContourMatrix() the row vector can come out of the for loop. Use .clear() or .fill() on it inside the loop, then you aren't reallocating.