Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing OpenCV:轮廓图像的近似分割_Image Processing_Opencv_Image Segmentation - Fatal编程技术网

Image processing OpenCV:轮廓图像的近似分割

Image processing OpenCV:轮廓图像的近似分割,image-processing,opencv,image-segmentation,Image Processing,Opencv,Image Segmentation,我试图找到一种对墓地图像进行近似分割的方法(在文化科学的CBIR背景下——但这不是主题)。到目前为止,我正在使用以下策略: 模糊图像两次(实验结果) 应用Canny边缘检测器 寻找轮廓 int main(int argc, const char* argv[]) { cout << "Starting " << endl; Mat sourceImage; sourceImage = imread("singlesegmentation/DSCN5204.JPG",

我试图找到一种对墓地图像进行近似分割的方法(在文化科学的CBIR背景下——但这不是主题)。到目前为止,我正在使用以下策略:

  • 模糊图像两次(实验结果)
  • 应用Canny边缘检测器
  • 寻找轮廓

    int main(int argc, const char* argv[]) {
    
    cout << "Starting " << endl;
    Mat sourceImage;
    sourceImage = imread("singlesegmentation/DSCN5204.JPG",
            CV_LOAD_IMAGE_COLOR);
    
    if (!sourceImage.data) {
        cout << "No Image found." << endl;
        return -1;
    }
    
    cv::Mat blurred = imagePro::blurrNtimes(2, sourceImage);
    cv::Mat target = edged::applyCanny(blurred);
    cout << "Canny applied " << endl;
    
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;
    cv::Point offset;
    offset.x = sourceImage.rows / 2;
    offset.y = sourceImage.cols / 2;
    cv::findContours(target, contours, hierarchy, CV_RETR_TREE ,
            CV_CHAIN_APPROX_SIMPLE, offset);
    cout << "Contours applied " << endl;
    
    int idx = 0;
    for (; idx >= 0; idx = hierarchy[idx][0]) {
        Scalar color(rand() & 255, rand() & 255, rand() & 255);
        drawContours(target, contours, idx, color, CV_FILLED, 8, hierarchy);
    }
    cout << "Lines applied " << endl;
    
    cv::namedWindow("Contour", CV_WINDOW_NORMAL);
    cv::imshow("Contour", target);
    cv::waitKey(0);
    
    return 0;
    
    int main(int argc,const char*argv[]{
    
    cout您可以尝试使用Hough变换(cv::HoughLinesP)参见教程示例


    为了找到图片中石头的坐标,你需要计算通过hough变换找到的线的交点。我使用高斯模糊,然后是拉普拉斯变换(而不是canny边)对于类似的用例。

    Class hough transform应用程序,probablistic HT还为您提供端点,并允许您过滤掉太短的线条