A
A
Alexander Kislinsky2017-03-08 01:27:54
C++ / C#
Alexander Kislinsky, 2017-03-08 01:27:54

What type should be specified in mat.at to read all channels in CV_16SC2?

This type for me (CV_16SC2) is quite specific and new, I do not understand what size one pixel of a two-channel matrix has.
Here I want to use exactly mat.at, and not follow the pointer, a place that does not require high speed.
The following code gives this output:

coord_mat = Mat::ones(img.size[0], img.size[1], CV_16SC2);
for (int y = 0; y < img.size[0]; ++y) {
    for (int x = 0; x < img.size[1]; ++x) {
        cout << coord_mat.at<Vec2s>(Point(x,y)) << " " << y << " " << x << endl;
    }
}

The numbers in brackets are the values ​​of the first and second pixel channels, the next 2 numbers are the row and column
[1, 0] 0 0
[1, 0] 0 1
[1, 0] 0 2
[1, 0] 0 3
[1, 0] 0 4
[1, 0] 0 5
[1, 0] 0 6
[1, 0] 0 7
[1, 0] 0 8
[1, 0] 0 9
[1, 0] 0 10
[1, 0] 0 11
[1, 0] 0 12
[1, 0] 0 13
[1, 0] 0 14
[1, 0] 0 15
[1, 0] 0 16
[1, 0] 0 17
[1, 0] 0 18
[1, 0] 0 19
[1, 0] 0 20
[1, 0] 0 21
[1, 0] 0 22
[1, 0] 0 23
[1, 0] 0 24

It is clearly seen that the type is not correct, since it should have been [1, 1] in square brackets.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2017-03-09
@D3Nd3R

If you are using VS then install the image watch plugin. And see what a particular pixel really contains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question