Use std::vector instead of cv::Mat:     KMeans(cv::Mat image, int K) {
        this->image = image;
        this->K = K;
        labels = cv::Mat::zeros(cv::Size(image.cols, image.rows), CV_8UC1);
        for (int i = 0; i < K; i++) {
            int randRow = random(image.rows - 1);
            int randCol = random(image.cols - 1);
            cv::Vec3b bgr_pixel = image.at<cv::Vec3b>(randRow, randCol);
            uchar b = bgr_pixel[0];
            uchar g = bgr_pixel[1];
            uchar r = bgr_pixel[2];
            clusterCentres.push_back(Pixel(b, g, r));
        }
        assignNewClusterCentres();
    }
