资源简介
ex6btr.zip
代码片段和文件信息
#include “cv.h“
#include “highgui.h“
#include “stdio.h“
#include “math.h“
#include “iostream.h“
int main()
{
//-----------------------------------开创内存空间,载入图像--------------------------------
IplImage *img*gimg*edge*cedge*rimg*result1*result2*result3;//*result4;
img=cvLoadImage(“水果1.jpg“);
cvNamedWindow(“水果“1);
cvShowImage(“水果“img);
int N_line=0;
int count=0;
gimg=cvCreateImage(cvSize(img->widthimg->height)81);
edge=cvCreateImage(cvSize(img->widthimg->height)81);
cedge=cvCreateImage(cvSize(img->widthimg->height)81);
rimg=cvCreateImage(cvSize(img->widthimg->height)81);
cvNot(rimgrimg);
result1=cvCreateImage(cvSize(img->widthimg->height)81);
result2=cvCreateImage(cvSize(img->widthimg->height)81);
result3=cvCreateImage(cvSize(img->widthimg->height)81);
cvNot(result1result1);
cvNot(result2result2);
cvNot(result3result3);
//------------------------图像阈值化处理----------------------------------------
cvCvtColor(imggimgCV_BGR2GRAY);//灰度图转化
cvSmooth(gimgedgeCV_BLUR330);//高斯模糊
cvDilate(gimggimgNULL1);
cvNamedWindow(“灰度图像“1);
cvShowImage(“灰度图像“gimg);
CvMemStorage *store;
CvSeq *outline;
double thread=200;//设立阈值
cvSmooth(gimgedgeCV_BLUR330);
cvNot(gimgedge);
cvThreshold(gimgedgethread255CV_THRESH_BINARY);
cvNot(edgeedge);
IplConvKernel *space=cvCreateStructuringElementEx(4422CV_SHAPE_ELLIPSENULL);
cvDilate(edgeedgespace1);
cvErode(edgeedgespace1);
cvNamedWindow(“二值图像“1);
cvShowImage(“二值图像“edge);
//------------------------边缘提取----------------------------------------
cvCanny(edgecedgethreadthread*73);
// cvThreshold(gimgedge(double)edge_t255CV_THRESH_BINARY);
store=cvCreateMemStorage(0);
cvCreateSeq(CV_SEQ_ELTYPE_POINTsizeof(CvSeq)sizeof(CvPoint)store);
N_line=cvFindContours(cedgestore&outlinesizeof(CvContour)CV_RETR_LISTCV_CHAIN_APPROX_SIMPLEcvPoint(00));
cout<<“ the number of outline:“< // printf(“nCon=%d“nCon);
//------------------------建立分类标准,图像分类----------------------------------------
for(;outline;outline=outline->h_next)
{
if(outline->total<8)
continue;
if(count%2==0)
{
cvDrawContours(rimgoutlineCV_RGB(000)CV_RGB(000)018cvPoint(00));
cvNamedWindow(“边缘轮廓“1);
cvShowImage(“边缘轮廓“rimg);
double arealength;
area=(cvContourArea(outlineCV_WHOLE_SEQ)+fabs(cvContourArea(outline->h_nextCV_WHOLE_SEQ)));
area/=2;
length=(cvArcLength(outlineCV_WHOLE_SEQ-1)+fabs(cvArcLength(outline->h_nextCV_WHOLE_SEQ-1)));
length/=2;
printf(“\n area=%f\n length=%f\n“arealength);
double roundper;
roundper=4*3.14*fabs(area)/(fabs(length)*fabs(length));
printf(“ roundper=%5f\n“roundper);
if(roundper<0.6&&area>=4000)
{
cvDrawContours(result1outlineCV_RGB(000)CV_RGB(000)0CV_FILLED8cvPoint
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-10-20 12:11 水果识别\
文件 4100 2012-06-13 17:19 水果识别\123.cpp
文件 34860 2012-06-08 16:03 水果识别\水果1.jpg
相关资源
- 64466UniPatcher_v2017.4.rar
- 马士兵版坦克大战.zip
- 百度地址.txt
- 2fp2iu.zip
- 02-Spark离线和实时电影推荐系统直播回
- gps.pdf
- Unity破解工具_UniPatcher2018_v1.zip
- 安卓1003个实战项目pdf.zip
- 共享单车.txt
- bookstore.rar
- gamehelp2.rar
- Qt_USB_I2C_MPU6050.rar
- 智慧考试ewei_examV3.9.2.1.rar
- d5xpwu.dic
- 中国银行签名说明.pdf
- WORKNC17后处理.rar
- visio2010_150911.rar
- e
- terrasolid.txt
- 单片机密码锁.zip
- ASM1117.7z
- TX-1C.DSN
- ZooKeeper分布式专题与Dubbo微服务入门
- 价值2K的H漫画小说系统.zip
- 2018新手完完全全学抓鸡教程.zip
- 2018.12.18更新高度匿名过狗中国菜刀
- 9——数字时钟.DSN
- SHL_verbal题库大全.doc
- 数据结构及应用算法教程参考答案.
- 卫星位置解算.rar
评论
共有 条评论