Ask Your Question

suu's profile - activity

2020-05-29 07:51:09 -0600 marked best answer having trouble to access to pixels in ROI
    Rect roi(0, 0, W / 3, H);

    Mat Roi_1 = image_gray(roi);

    int h_1 = Roi_1.rows;
    int w_1 = Roi_1.cols;

    int sum1 = 0;

    int mean1  = 0;

    int x, y;

    uchar* Data_1 = Roi_1.data;

    for (y = 0; y < h_1; y++) {
        for (x = 0; x < w_1; x++) {
            sum1 += Data_1[y * w_1, +x];
        }
    }

    mean1 = sum1 / (h_1 * w_1);

I want to get mean value of pixels on the left side of the image

so I set the ROI and read the pixels value of ROI

but it returns the upside mean values not left side

I think my code read the original image("image_gray"), not the ROI

I don't know what can I do

2020-05-28 05:33:44 -0600 commented answer having trouble to access to pixels in ROI

it works, you save my life.

2020-05-28 04:13:33 -0600 asked a question having trouble to access to pixels in ROI

having trouble to access to pixels in ROI Rect roi(0, 0, W / 3, H); Mat Roi_1 = image_gray(roi); int h_1 =