【问题标题】:Detect clip arts or vectorial images using OpenCV in C++在 C++ 中使用 OpenCV 检测剪贴画或矢量图像
【发布时间】:2011-07-14 20:29:42
【问题描述】:

我有一个使用 SURF 检测相似图像的过程,我想添加一个检查以了解哪些图像是真实的相机照片,哪些是矢量图像,例如地图屏幕截图的徽标。

示例

照片:http://images.gta-travel.com/HH/Images/J/TYO/TYO-NEW3-8.jpg

标志:http://estaticos.transhotel.com/img/fotos/hoteles/000137/hft000137578_005.jpg

标志:http://live.viajesurbis.com/vuweb/content/fichashotel/13127/HOTEL_13127_2.jpg

我尝试查看灰色直方图(和颜色直方图),但没有提供足够的信息来知道哪个是矢量。

【问题讨论】:

    标签: c++ image opencv histogram surf


    【解决方案1】:

    好的,解决了,下一个代码是清理直方图,获取所有颜色的灰度并计算不同的颜色。也许将来我会测试使用组件直方图是否会改进算法。

    CvHistogram* wImage::getHistogram() {
        IplImage* gray = cvCreateImage(cvGetSize(this->image), 8, 1);
    
        CvHistogram* hist;
        int hist_size = 256;
        float range[] = {0, 256};
        float* ranges[] = {range};
    
        cvCvtColor(this->image, gray, CV_RGB2GRAY);
        hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
        cvCalcHist(&gray, hist, 0, NULL);
    
        return hist;
    }
    
    bool wImage::isVectorial() {
    
        CvHistogram* hist = this->getHistogram();
    
        int height = 240;
    
        float max_value = 0, min_value = 0;
        cvGetMinMaxHistValue(hist, &min_value, &max_value);
    
        int total = 0;
        int colors = 0;
    
        float value;
        int normalized;
    
        for(int i=0; i < 256; i++){
            value = cvQueryHistValue_1D(hist, i);
            normalized = cvRound(value * height / max_value);
    
            if(normalized < 2 || normalized > 230) {
                continue;
            }
    
            colors++;
            total += normalized;
        }
    
        if((total < 500 && colors < 100) || (total < 1000 && colors < 85)) {
            return true;
        }
    
        return false;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 2019-12-06
      • 1970-01-01
      • 2020-10-18
      相关资源
      最近更新 更多