将opencv c ++代码中的函数转换为java

时间:2017-03-24 12:56:14

标签: java opencv

我在C ++中有以下代码。

Mat getMedianDarkChannel(Mat src, int patch)
{
    Mat rgbmin = Mat::zeros(src.rows, src.cols, CV_8UC1);
    Mat MDCP;
    Vec3b intensity;

    for(int m=0; m<src.rows; m++)
    {
        for(int n=0; n<src.cols; n++)
        {
            intensity = src.at<Vec3b>(m,n);
            rgbmin.at<uchar>(m,n) = min(min(intensity.val[0],intensity.val[1]), intensity.val[2]);

        }
    }
    medianBlur(rgbmin, MDCP, patch);
    return MDCP;

}

如何解决java中嵌套for循环内部的问题?谢谢〜

1 个答案:

答案 0 :(得分:0)

    Mat getMedianDarkChannel(Mat src, int patch) {

    Mat rgbmin = Mat.zeros(src.size(), src.type());
    Mat MDCP;
    Vec3b intensity;
    for (int m = 0; m < src.rows(); m++) {
        for (int n = 0; n < src.cols(); n++) {
            intensity = src.get(m, n);
            rgbmin.get(m, n) = Math.min(Math.min(intensity.val.indexOf(0), intensity.val.indexOf(1)), intensity.val.indexOf(2));

        }
    }
    medianBlur(rgbmin, MDCP, patch);
    return MDCP;

}