• 大小: 3.82MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-10
  • 语言: C/C++
  • 标签: 区域生长  

资源简介

区域生长法VS实现。C++

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “growing.h“

g_point::g_point(int x_i int y_i)  
{  
x = x_i;  
y = y_i;  
lbl = SEED;  
}  

g_point::g_point()  
{  
x = 0;  
y = 0;  
lbl = INIT;  
}  

g_point::g_point(int x_i int y_i int lbl_i)  
{  
x = x_i;  
y = y_i;  
lbl = lbl_i;  
}  

void regionGrowth(IplImage* img int* p_mat int x_g int y_g int threshold_g)  
{  
//常用变量:  
int x;  
int y;  
int gradient = 0;  

//设置前次边缘点  
std::list cont_pts_pre;  
std::list * pcont_pts_pre = &cont_pts_pre;


//设置边缘点  
std::list cont_pts;  
std::list * pcont_pts = &cont_pts;


//种子点+边缘点 = 下次的种子点  
//上次的边缘点 = 前次边缘点(用于下次减少点数)   
cont_pts_pre.push_back(class g_point(x_g y_g CONT));  
p_mat[y_g * img->width + x_g] = SEED;  

std::list::iterator iter_cont;  
std::list::iterator iter_prt;  
std::list::iterator iter_swap;  

while( !cont_pts_pre.empty() )  
{  

//一轮生长  
iter_cont = cont_pts_pre.begin();  
while(iter_cont != cont_pts_pre.end())  
{  
x = (*iter_cont).x;  
y = (*iter_cont).y;  
if( !(x-1<0 || y-1<0) )                       //#1  
{     
if(p_mat[(y-1)*img->width + (x-1)] == INIT)  
{  
gradient = ((char*)(img->imageData + y*img->widthStep))[x] -   
((char*)(img->imageData + (y-1)*img->widthStep))[x-1];  
if(abs(gradient) < threshold_g)      //满足阈值要求  
{  
cont_pts.push_back(class g_point(x-1 y-1 CONT));  
p_mat[(y-1)*img->width + (x-1)] = SEED;  
}  
else                                //不满足阈值要求  
{  
p_mat[(y-1)*img->width + (x-1)] = INVAL;  
}  
}  
}  
if( !(x-1<0) )                                   //#2  
{  
if(p_mat[(y)*img->width + (x-1)] == INIT)  
{  
gradient = ((char*)(img->imageData + y*img->widthStep))[x] -   
((char*)(img->imageData + (y)*img->widthStep))[x-1];  
if(abs(gradient) < threshold_g)      //满足阈值要求  
{  
cont_pts.push_back(class g_point(x-1 y CONT));  
p_mat[(y)*img->width + (x-1)] = SEED;  
}  
else                                //不满足阈值要求  
{  
p_mat[(y)*img->width + (x-1)] = INVAL;  
}         

}  
}  
if( !(x-1<0 || y+1 >= img->height) )           //#3  
{  
if(p_mat[(y+1)*img->width + (x-1)] == INIT)  
{  
gradient = ((char*)(img->imageData + y*img->widthStep))[x] -   
((char*)(img->imageData + (y+1)*img->widthStep))[x-1];  
if(abs(gradient) < threshold_g)      //满足阈值要求  
{  
cont_pts.push_back(class g_point(x-1 y+1 CONT));  
p_mat[(y+1)*img->width + (x-1)] = SEED;  
}  
else                                //不满足阈值要求  
{  
p_mat[(y+1)*img->width + (x-1)] = INVAL;  
}  

}  
}  
if( !(y+1 >= img->height) )                    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      93696  2016-04-05 16:24  Growing4-5\Debug\Growing4-5.exe

     文件    1280904  2016-04-05 16:24  Growing4-5\Debug\Growing4-5.ilk

     文件    1838080  2016-04-05 16:24  Growing4-5\Debug\Growing4-5.pdb

     文件       1990  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\cl.command.1.tlog

     文件      43664  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\CL.read.1.tlog

     文件       2304  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\CL.write.1.tlog

     文件     337363  2016-04-05 16:22  Growing4-5\Growing4-5\Debug\growing.obj

     文件         75  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\Growing4-5.lastbuildstate

     文件       2281  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\Growing4-5.log

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link-cvtres.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link-cvtres.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link-rc.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link-rc.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900-cvtres.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900-cvtres.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900-rc.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900-rc.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.1900.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132-cvtres.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132-cvtres.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132-rc.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132-rc.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5132.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5296-cvtres.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5296-cvtres.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5296-rc.read.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5296-rc.write.1.tlog

     文件          2  2016-04-05 16:24  Growing4-5\Growing4-5\Debug\link.5296.read.1.tlog

............此处省略32个文件信息

评论

共有 条评论