⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhixin.cpp

📁 用于对含有较粗光带的图像处理时对光带的中心线进行提取的操作
💻 CPP
字号:
#include "stdafx.h"
#include "zhixin.h"
#include "cdib.h"
void  Zhixinfa(CDib * pDib, double * pdGrad,int pCounter,int *pXnew,int *pYnew)
{
	// 遍历图象的纵坐标
	int y;
	
	// 遍历图象的横坐标
	int x;
	
	// 图象的长宽大小
	CSize sizeImage		= pDib->GetDimensions();
	int nWidth			= sizeImage.cx		;
	int nHeight			= sizeImage.cy		;
	
	// 图像在计算机在存储中的实际大小
	CSize sizeImageSave	= pDib->GetDibSaveDim();
	
	// 图像在内存中每一行象素占用的实际空间
	int nSaveWidth = sizeImageSave.cx;
	
	// 图像数据的指针
	LPBYTE  pImageData = pDib->m_lpImage;
	
	// 初始化
	for(y=0; y<nHeight ; y++ )
		for(x=0 ; x<nWidth ; x++ )
		{
			*(pdGrad+y*nWidth+x)=0;
		}
		
		
		
	int Xcount=0;
	int Ycount=0;
	int PixelCount=0;
	int YColumm=0;
		
	for(x=1;x<nWidth-2;x++)
	{   
		pYnew[pCounter]=0;
			
			
			
		for( y=1 ; y<nHeight-2; y++)
		{  
			Ycount=PixelCount=0;
			for(int jZ=y-1;jZ<=y+1;jZ++)
			{
				for(int iZ=x-1;iZ<=x+1;iZ++)
				{
					Ycount+=(jZ* (*(pImageData+jZ*nSaveWidth+iZ))  );
					PixelCount +=(*(pImageData+jZ*nSaveWidth+iZ));
				}
			}	
				
			if(Ycount!=0)
			{
				YColumm=int(Ycount/PixelCount);
					
				if(  *(pImageData+pYnew[pCounter]*nSaveWidth+x) <
					*(pImageData+YColumm*nSaveWidth+x)    )
				{
					pYnew[pCounter]=YColumm;
				}
					
			}
				
				
		}
		if(pYnew[pCounter]!=0)
		{
			pXnew[pCounter]=x;
			pCounter++;
		}
			
	}
		
		
	for(int ip=0;ip<pCounter;ip++)
	{
		*(pdGrad+pYnew[ip]*nWidth+pXnew[ip])=255;
	}
}
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -