Ask Your Question

Revision history [back]

Program to output the coordinates of all white pixels in a binary mat?

Hello, this might be basic, but I can't find the simple answer anywhere. I have a mat ( see example code) going through an HSV filter to the color I want to detect, which is great, I get a highlighted binary (black and white) image of the region I want. Then, I want to create a new array or mat of the coordinates of each pixel that is lit white (or black) so I can calculate the average coordinate of each pixel. Here's my (relevant section of) code so far. What would be the next step?

        double resizeImageWidth = 640.0;
        double resizeImageHeight = 480.0;
        int resizeImageInterpolation = Imgproc.INTER_CUBIC;
        resizeImage(m, resizeImageWidth, resizeImageHeight, resizeImageInterpolation, resizeImageOutput);

        double[] hsvThresholdHue = {0.0, 61.587455090159565};
        double[] hsvThresholdSaturation = {116.95143884892086, 255.0};
        double[] hsvThresholdValue = {0.0, 255.0};
        hsvThreshold(resizeImageOutput, hsvThresholdHue, hsvThresholdSaturation, hsvThresholdValue,