My name is Baum, and I'm too excited about OpenCV and the program.
OpenCV execution environment is as follows.
- OpenCV 3.4.8
I want to get the pixel value of the specified row in the following grayscale image (640x480).
type specification in several ways, but when I check the acquired value,expected value (0 to 255)is thrown into the array did not.
If i find something wrong, please let me know.
Below is the source code to get the value of the 240th line of the above image.
Some are omitted for easy viewing.
unsigned int tget_line [640];// Information for each pixel of the specified line (expects 0 to 255 to be stored)
int main (int argh, char * argv [])
{
Mat gray = imread ("bin.png", IMREAD_COLOR);// Assign the prepared grayscale image to Mat gray
int x;
int y = 240;// Specify the line (specify the 240th center line of h = 480)
for (x = 0;x<640;++ x)
{
tget_line [x] = gray.at<int>(y, x);
printf ("% d, \ n,", tget_line [x]);
}
return 0;
}
The output tget_line [] value is as follows.
The black part has a positive value, and the white part has a negative value. These values are the results that are required in 0 to 255 levels.
-1717986919,
-1717986919,
-1717986919,
-1701143910,
-1717986662,
-1701143911,
-1734829928,
-1717987176,
-1717986919,
-1717986919,
-1717986919,
-1701143911,
-1717921126,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701209703,
-1717986662,
-1701143911,
-1717921126,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701143911,
-1717921126,
-1717986919,
-1701143911,
-1717921126,
-1717986919,
-1717986919,
-1701209703,
-1701143910,
-1717986918,
-1717986919,
-1701144167,
-1717986918,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701143911,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1734829927,
-1718052712,
-1717986919,
-1717986919,
-1717986919,
-1734829671,
-1734829928,
-1717986919,
-1717986919,
-1717986919,
-1734829928,
-1717987176,
-1717986919,
-1701209703,
-1717986662,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1734829927,
-1718052712,
-1717986919,
-1701143911,
-1717921126,
-1701144167,
-1717986918,
-1701209703,
-1717986662,
-1717986919,
-1734829928,
-1701144424,
-1701143910,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1734829927,
-1718052712,
-1717986919,
-1717986919,
-1734764135,
-1717987176,
-1734829927,
-1717986919,
-1734829671,
-1734829928,
-1717986919,
-1717986919,
-1734829927,
-1718052712,
-1717986919,
-1717986919,
-1734829928,
-1717987176,
-1717986919,
-1717986919,
-1734829671,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1751672936,
-1751672937,
-1734830185,
-1734829928,
-1734829928,
-1717987176,
-1717986919,
-1734829928,
-1734829928,
-1751672936,
-1734895721,
-1734829928,
-1751672936,-1751672937,
-1734830185,
-1751672936,
-1751672937,
-1751672937,
-1734829929,
-1751672937,
-1751672937,
-1751672937,
-1734895721,
-1751672680,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1768450153,
-1751673194,
-1751672937,
-1751672937,
-1751672937,
-1768515945,
-1768515946,
-1768515946,
-1768515946,
-1768515946,
-1768515946,
-1768515946,
-1751672937,
-1751672937,
-1734829929,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1768515945,
-1751738730,
-1751672937,
-1751672937,
-1751738730,
-1734830185,
-1751672936,
-1768515946,
-1751673194,
-1734829929,
-1768450153,
-1768515946,
-1768515946,
-1785293162,
-1819044459,
-1869573997,
1334282119,
471617359,
471604252,
505092891,
488447518,
471604253,
471538459,
471604252,
488447260,
438049820,
437918234,
437918234,
437918234,
421075482,
437918233,
421075225,
437917977,
421075226,
437852441,
421075482,
437918233,
421141018,
421075225,
421075225,
421075225,
421075225,
421075225,
404298009,
421074968,
404232217,
404232216,
387389464,
387389207,
404232216,
404232216,
387389208,
387455000,
387389207,
404232215,
387389207,
387389207,
370546199,
353768982,
387388693,
387389207,
353768982,
353703189,
370546197,
353768982,
353703189,
353703189,
404100630,
387389464,
370546199,
353703189,
353703189,
353703189,
336925973,
370545684,
387389206,
387323414,
353703703,
353703189,
353703189,
353703189,
353703189,
353703189,
336860437,
336860180,
353703189,
353703189,
353703189,
353703189,
353703189,
353703189,
353637396,
353703189,
353703189,
353703189,
353703189,
370546197,
353768982,
353703189,
353703189,
370414612,
370546198,
353703190,
370546198,
370546198,
370546198,
370480405,
370546198,
387389206,
387389207,
370546455,
370546198,
420943639,
320018713,
1482184723,
-1819308145,
-1802202221,
-1785358956,
-1768515946,
-1751673194,
-1751672937,
-1768515946,
-1768515946,
-1768515946,
-1768515946,
-1768515946,
-1751672938,
-1768450153,
-1768515946,
-1768515946,-1751672937,
-1751672937,
-1768515945,
-1751672937,
-1768515689,
-1751672938,
-1751672937,
-1751672937,
-1751672937,
-1768450153,
-1768515946,
-1768515946,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1734830185,
-1734829928,
-1734895721,
-1751672680,
-1751672937,
-1734895721,
-1734829928,
-1751672936,
-1734895721,
-1734829928,
-1751672936,
-1734895721,
-1751672680,
-1751672937,
-1734895721,
-1734829928,
-1734829928,
-1751672937,
-1734830185,
-1734829928,
-1734829928,
-1717987176,
-1717986919,
-1734829928,
-1734829928,
-1734829928,
-1701143910,
-1734829414,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1717986919,
-1734829671,
-1734829928,
-1717986919,
-1717986919,
-1717986919,
-1734829928,
-1717987176,
-1717986919,
-1717986919,
-1717986919,
-1701143911,
-1734764135,
-1717987176,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1734829927,
-1718052712,
-1701144167,
-1701143910,
-1717921126,
-1717986919,
-1717986919,
-1701143910,
-1701143910,
-1717986918,
-1717986919,
-1701144167,
-1701143910,
-1701143910,
-1717986662,
-1717986919,
-1701209703,
-1717986662,
-1701143911,
-1717921126,
-1717986919,
-1717986919,
-1701143910,
-1717986662,
-1701143911,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701078117,
-1701143910,
-1701143910,
-1684366694,
-1701143653,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1684300901,
-1701143653,
-1701143910,
-1701143910,
-1701143910,
-1684300902,
-1684300901,
-1701143653,
-1684300902,
-1684300901,
-1701143653,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701143910,
-1701078117,
-1701143910,
-1701143910,
-1684300901,
-1684300901,
-1701143909,
-1684300901,
-1684300901,
-1701143909,
-1684366694,
-1684300901,
-1684300901,
-1701078117,
-1701143910,
-1684300902,
-1684300901,
-1701143653,
-1701143910,-1684366694,
-1701143653,
-1684300902,
-1734764135,
-1734829928,
-1717986920,
-1717986919,
-1701144167,
-1701143910,
-1734829928,
-1717987176,
-1717986919,
-1701143910,
-1717986662,
-1701143911,
-1701143910,
-1717986662,
-1734829927,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701209703,
-1701143910,
-1717986918,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701143910,
-1717986662,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1701143911,
-1734764135,
-1734829928,
-1701143912,
-1717986919,
-1701144167,
-1701143910,
-1717986919,
-1717986919,
-1717986919,
-1734829928,
-1734829928,
-1734829928,
-1718052712,
-1717986919,
-1717986919,
-1717986919,
-1734829671,
-1717986920,
-1701143910,
-1701143910,
-1717986918,
-1734829928,
-1734829928,
-1717986920,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717921126,
-1717986919,
-1734829927,
-1734829928,
-1734829928,
-1717986920,
-1718052712,
-1717986919,
-1717986919,
-1701143910,
-1717986662,
-1717986919,
-1734764135,
-1734829928,
-1734829928,
-1734764135,
-1717987176,
-1701143911,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1717986919,
-1734829927,
-1734829928,
-1717987176,
-1717986919,
-1734764135,
-1717987176,
-1734829927,
-1718052712,
-1717986919,
-1717986919,
-1718052712,
-1717986919,
-1734829927,
-1734829928,
-1717987176,
-1717986919,
-1734829928,
-1734829928,
-1734829928,
-1734764135,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1734829928,
-1751672680,
-1751672937,
-1734895721,
-1734829928,
-1751672936,
-1751607144,
-1734830185,
-1734829928,
-1734895721,
-1734829928,
-1751672936,
-1734895721,
-1734829928,
-1751672936,
-1751672937,
-1734830185,
-1768515944,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1751672937,
-1768515945,
-1768450153,
-1768515946,
-1751672938,
-1768450153,
-1768515946,
-1768515946,
-1751738730,
This grayscale image seems to be unrelated to the question, but this grayscale image was converted to grayscale using the Mat frame image (YUV422) imported from the Web camera with the cvtColor function as the third argument CV_BGR2GRAY It is an image saved in Mat gray later.
cvtColor (frame, gray, CV_BGR2GRAY);
-
Answer # 1
Related articles
- how to extract and edit the rgb value of each pixel in an image (python)
- i want to pass an image from python to c ++
- i want to acquire a specific value by adding a condition to the column value from php db
- c ++ - about the return value of the constructor
- c ++ - questions about passing by value and passing by reference
- i want to group by a specific value between php associative arrays and aggregate them
- c ++ - i want to set an initial value for a static member variable
- i want to create a 3d array with c ++ and convert it to an image
- c ++ - i want to know the cause of the z-axis value being incorrect in the matrix used for screen drawing in glsl
- i want to get the target value in a specific table from multiple tables with python beautiful soup
- python - i want to put a specific value in column c up to the top n values in column b when column a meets a specific conditio
- python - i want to show the time series data of csv only more than a specific value
- google apps script - get the value of a specific column in a gas updated row and send an email
- java - receive a specific value in param method of mockmvc and want to test post method of controller class
- c ++:i want to define the value corresponding to enum in the header file
- linux - i want to add a fixed value to a specific position of a file without line feed code in the shell
- vba - post specified value to specific cell range
- javascript - [vuejs] search for a specific value from the multi-dimensional array and acquire the subordinate array
- linux - i want to add a fixed value to the end of a specific file in the shell
- i want to edit a specific value value in a php associative array
- c ++ - i want to execute g ++ of source code using opencv
- i want to pass an image from python to c ++
- c ++ - after reinstalling the pcl library, i can no longer build
- c ++ - cannot run openmpi on multiple machines in parallel on ubuntu 20041
- c ++ - i want to put a bgr image in the memory area of a dynamic object
- c ++ - i get an error when i try to compile opencv
- how to get the index of the maximum value of a matrix in a specific direction in c ++
- i get an error with c ++ opencv
- about the problem that characters are garbled when accessing the list of uint8_t in c ++
- c ++ - how to use cv :: vec3b
If it is a grayscale image, specify IMREAD_GRAYSCALE and read it as 8bit1ch.
In addition,
tget_line [x] = gray.at(y, x)
is replaced bygray.at(y, x)
?At present, images are read as 8bit3ch.
In that case, the pixel data of a row is
[B0] [G0] [R0] [B1] [G1] [R1] [B2] [G2] [R2] ...
(Please think that one [] is 1 byte).
1 pixel information is 3 bytes.
I'm trying to read this as an int (forcing the int size to be 4 bytes)
[B0] [G0] [R0] [B1] [G1] [R1] [B2] [G2] [R2] [B3] [G3] [R3] ...
In this form, the memory contents every 4 bytes are interpreted as ints.