opencv组件

  • Trackbar

手动调整Trackbar可以得到值,然后根据值进行高斯滤波。


void on_trackbar(int slideValue, void*) {
    Mat imFiltered;
    //要为奇数
    GaussianBlur(src, imFiltered, Size(slideValue/2*2+1, slideValue / 2 * 2 +1), 0);
    imshow(windowName,imFiltered);
}

int main() {
    int slideValue;
    src = imread("lena.jpg");
    namedWindow(windowName,WINDOW_FREERATIO);
    createTrackbar("myTrackBar",windowName, &slideValue, maxSlideValue, on_trackbar);
    on_trackbar(0, NULL);


END:
    waitKey(0);
    system("pause");
    return 0;
}

  • 定义Pixel
typedef Vec3b Pixel;
typedef Point_<uchar> Pixel;
typedef Point3_<uchar> Pixel;
  • Mat迭代器与const Mat迭代器
MatIterator_<Pixel> rgb_first = rgb_image.begin<Pixel>();
MatIterator_<Pixel> rgb_end = rgb_image.end<Pixel>();
MatConstIterator_<int> labes_first = labels.begin<int>();

推荐阅读更多精彩内容