手机版

图像分割(阈值分割和区域生长)vc++代码

时间:2025-07-03   来源:未知    
字号:

实验6 图像分割

1、 阈值分割法

实验代码及结果:

#include "cv.h"

#include "highgui.h"

#include "stdio.h"

#include "stdlib.h"

#include <math.h>

int main( int argc, char** argv )

{

IplImage* pImg=0; //声明IplImage指针

int height,width,step,channels;

uchar *data;

int i,j;

//载入图像

pImg = cvLoadImage("2.jpg",0); if( !pImg )

{

printf("Image was not loaded.\n");

return -1;

}

//获取图像信息

height=pImg->height; width=pImg->width; step=pImg->widthStep; channels=pImg->nChannels; data=(uchar *)pImg->imageData; printf("Processing a %d*%d with %d channels\n",height,width,channels); int MaxP=0; float t,T,m=0,n=0; float w0,w1,u0,u1,u;

double q2=0,temp=0;

cvNamedWindow( "win1", 1);//创建窗口

cvShowImage( "win1", pImg );//显示图像

//计算最大灰度值MaxP

for(i=0;i<height;i++) for(j=0;j<width;j++)

图像分割(阈值分割和区域生长)vc++代码.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)