Generate binary image using coordinate vectors
auto
Automatic type deduction is especially welcoming for iterators, as their types are bulky. We can rewrite to
std::vector&lt;std::vector&lt;double&gt;&gt; x;
std::vector&lt;std::vector&lt;double&gt;&gt; y;

// fill x and y

std::vector&lt;std::vector&lt;unsigned int&gt;&gt; M(n_rows, std::vector&lt;unsigned int&gt;(n_cols));

auto iter_row_x = x.cbegin(); //note cbegin to get const_iterator
auto iter_row_y = y.cbegin();

for (; iter_row_x != x.end(); ++iter_row_x, ++iter_row_y) {
    auto iter_col_x = iter_row_x-&gt;cbegin(); // iter_row_x[0].cbegin() = iter_row_x-&gt;cbegin()
    auto iter_col_y = iter_row_y-&gt;cbegin();
    for (; iter_col_x != iter_row_x[0].end(); ++iter_col_x, ++iter_col_y) {
        auto i = static_cast&lt;unsigned int&gt;(*iter_col_x); // be explicit about which cast you are using. Now you do not need to specify the type twice.
        auto j = static_cast&lt;unsigned int&gt;(*iter_col_y);
        M[i][j] = 1;
    }
}

But it's still wordy. Having separate vectors for x and y seems unnecessary, since it is expected that they should be of same length. Better create a structure for xy and create only one vector.
struct Point 
{
    double x;
    double y;
}

Then we have
std::vector&lt;std::vector&lt;Point&gt;&gt; xy;

// fill xy

std::vector&lt;std::vector&lt;unsigned int&gt;&gt; M(n_rows, std::vector&lt;unsigned int&gt;(n_cols));

for (auto iter_row_xy = xy.cbegin() ; iter_row_xy != xy.end(); ++iter_row_xy) {
    for (auto iter_col_xy = iter_row_xy-&gt;cbegin(); iter_col_x != iter_row_x[0].end(); ++iter_col_x, ++iter_col_y) {
        auto i = static_cast&lt;unsigned int&gt;(*iter_col_xy.x);
        auto j = static_cast&lt;unsigned int&gt;(*iter_col_xy.y);
        M[i][j] = 1;
    }
}

But we can do even better by using for range:
std::vector&lt;std::vector&lt;Point&gt;&gt; xy;

// fill xy

std::vector&lt;std::vector&lt;unsigned int&gt;&gt; M(n_rows, std::vector&lt;unsigned int&gt;(n_cols));

for (const auto&amp; elements : xy){
    for (const auto&amp; point : elements){
        auto i = static_cast&lt;unsigned int&gt;(point.x);
        auto j = static_cast&lt;unsigned int&gt;(point.y);
        M[i][j] = 1;
    }
}