简体   繁体   English

使用OpenCV Haar级联分类器查找形状

[英]Finding shapes using OpenCV Haar cascaded classifier

I am looking for parabolas in some radar data. 我在一些雷达数据中寻找抛物线。 I am using the OpenCV Haar cascaded classifier. 我正在使用OpenCV Haar级联分类器。 My positive images are 20x20 PNGs where all of the pixels are black, except for those that trace a parabolic shape--one parabola per positive image. 我的正面图像是20x20 PNG,其中所有像素都是黑色的,除了那些跟踪抛物线形状的像素 - 每个正像的一个抛物线。

My question is this: will these positives train a classifier to look for black boxes with parabolas in them, or will they train a classifier to look for parabolic shapes? 我的问题是:这些积极因素会训练分类器寻找带有抛物线的黑匣子,还是会训练分类器来寻找抛物线形状?

Should I add a layer of medium value noise to my positive images, or should they be unrealistically crisp and high contrast? 我应该在正片上添加一层中等噪音,还是应该是不切实际的清晰和高对比度?

Here is an example of the original data. 这是原始数据的示例。

原始数据。

Here is an example of my data after I have performed simple edge detection using GIMP. 以下是使用GIMP执行简单边缘检测后的数据示例。 The parabolic shapes are highlighted in the white boxes 抛物线形状在白色框中突出显示

边缘检测后的数据。

Here is one of my positive images. 这是我的一个积极形象。

样本正面图像。

I figured out a way to do detect parabolas initially using the MatchTemplate method from OpenCV. 我想出了一种最初使用OpenCV中的MatchTemplate方法检测抛物线的方法。 At first, I was using the Python cv , and later cv2 libraries, but I had to make sure that my input images were 8-bit unsigned integer arrays. 起初,我使用的是Python cv ,后来是cv2库,但我必须确保输入的图像是8位无符号整数数组。 I eventually obtained a similar effect with less fuss using scipy.signal.correlate2d( image, template, mode='same') . 我最终使用scipy.signal.correlate2d( image, template, mode='same')获得了类似的效果而不那么大惊小怪。 The mode='same' resizes the output to the size of image . mode='same'将输出调整为image大小。 When I was done I performed thresholding, using the numpy.where() function, and opening and closing to eliminate salt and pepper noise using the scipy.ndimage module. 当我完成时,我使用numpy.where()函数执行阈值处理,并使用scipy.ndimage模块打开和关闭消除盐和胡椒噪音。

Here's the output, before thresholding. 这是输出,在阈值处理之前。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM