多种亚像素计算方法


用于边缘检测的很多方法,并且考虑的精度要求用到了亚像素,比如空间矩的方法
资源截图
代码片段和文件信息
// cdib.cpp

#include “stdafx.h“
#include “math.h“
#include “process.h“

#include “cdib.h“
#include “GlobalApi.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// 实例化串行化过程
IMPLEMENT_SERIAL(CDib Cobject 0);


/*************************************************************************
 *
 * 函数名称:
 *   CDib()
 *
 * 输入参数:
 * 无
 *
 * 返回值:
 *   无
 *
 * 说明:
 *   构造函数
 *
 ************************************************************************
 */
CDib::CDib()
{
m_hFile      = NULL;
m_hBitmap    = NULL;
m_hPalette   = NULL;
m_nBmihAlloc = m_nImageAlloc = noAlloc;
Empty();
}


/*************************************************************************
 *
 * 函数名称:
 *   CDib()
 *
 * 输入参数:
 * CSize size - 位图尺寸
 * int nBitCount - 象素位数
 *
 * 返回值:
 *   无
 *
 * 说明:
 *   构造函数
 *   根据给定的位图尺寸和象素位数构造CDib对象,并对信息头和调色板分配内存
 *   但并没有给位图数据分配内存
 *
 ************************************************************************
 */
CDib::CDib(CSize size int nBitCount)
{
m_hFile      = NULL;
m_hBitmap    = NULL;
m_hPalette   = NULL;
m_nBmihAlloc = m_nImageAlloc = noAlloc;
Empty();

// 根据象素位数计算调色板尺寸
ComputePaletteSize(nBitCount);

// 分配DIB信息头和调色板的内存
m_lpBMIH = (LPBITMAPINFOHEADER) new 
char[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * m_nColorTableEntries];

// 设置信息头内存分配状态
m_nBmihAlloc = crtAlloc;

// 设置信息头中的信息
m_lpBMIH->biSize = sizeof(BITMAPINFOHEADER);
m_lpBMIH->biWidth = size.cx;
m_lpBMIH->biHeight = size.cy;
m_lpBMIH->biPlanes = 1;
m_lpBMIH->biBitCount = nBitCount;
m_lpBMIH->biCompression = BI_RGB;
m_lpBMIH->biSizeImage = 0;
m_lpBMIH->biXPelsPerMeter = 0;
m_lpBMIH->biYPelsPerMeter = 0;
m_lpBMIH->biClrUsed = m_nColorTableEntries;
m_lpBMIH->biClrImportant= m_nColorTableEntries;

// 计算图象数据内存的大小,并设置此DIB的调色板的指针
ComputeMetrics();

// 将此DIB的调色板初始化为0
memset(m_lpvColorTable 0 sizeof(RGBQUAD) * m_nColorTableEntries);

// 暂时不分配图象数据内存
m_lpImage = NULL; 
}


/*************************************************************************
 *
 * 函数名称:
 *   ~CDib()
 *
 * 输入参数:
 * 无
 *
 * 返回值:
 *   无
 *
 * 说明:
 *   析构函数,并释放所有分配的DIB内存
 *
 ************************************************************************
 */
CDib::~CDib()
{
Empty();
}


/*************************************************************************
 *
 * 函数名称:
 *   GetDimensions()
 *
 * 输入参数:
 *   无
 *
 * 返回值:
 *   CSize - DIB的宽度和高度
 *
 * 说明:
 *   返回以象素表示的DIB的宽度和高度
 *
 ************************************************************************
 */
CSize CDib::GetDimensions()
{
if(m_lpBMIH == NULL) return CSize(0 0);
return CSize((int) m_lpBMIH->biWidth (int) m_lpBMIH->biHeight);
}


/*************************************************************************
 *
 * 函数名称:
 *   AttachMapFile()
 *
 * 输入参数:
 *   const char* strPathname - 映射文件的路径名
 *   BOOL bShare

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

     文件      38873  2012-01-13 08:46  Edge_detectioncdib.cpp

     文件       3663  2007-06-02 17:47  Edge_detectioncdib.h

     文件      11948  2012-01-13 14:25  Edge_detectionDebugBuildLog.htm

     文件      93556  2012-01-13 08:46  Edge_detectionDebugcdib.obj

     文件          0  2012-01-13 08:46  Edge_detectionDebugcdib.sbr

     文件      30411  2012-01-13 08:47  Edge_detectionDebugDIBPrcs.obj

     文件          0  2012-01-13 08:47  Edge_detectionDebugDIBPrcs.sbr

     文件    9374720  2012-01-13 14:25  Edge_detectionDebugEdge_detection.bsc

     文件     206848  2012-01-13 14:25  Edge_detectionDebugEdge_detection.exe

     文件        920  2012-01-13 08:49  Edge_detectionDebugEdge_detection.exe.embed.manifest

     文件        984  2012-01-13 08:49  Edge_detectionDebugEdge_detection.exe.embed.manifest.res

     文件        861  2012-01-13 14:25  Edge_detectionDebugEdge_detection.exe.intermediate.manifest

     文件    1823960  2012-01-13 14:25  Edge_detectionDebugEdge_detection.ilk

     文件      36447  2012-01-13 08:39  Edge_detectionDebugEdge_detection.obj

     文件   28704768  2012-01-13 08:39  Edge_detectionDebugEdge_detection.pch

     文件    4082688  2012-01-13 14:25  Edge_detectionDebugEdge_detection.pdb

     文件       7908  2012-01-13 08:49  Edge_detectionDebugEdge_detection.res

     文件          0  2012-01-13 08:39  Edge_detectionDebugEdge_detection.sbr

     文件      27070  2012-01-13 08:39  Edge_detectionDebugEdge_detectionDoc.obj

     文件          0  2012-01-13 08:39  Edge_detectionDebugEdge_detectionDoc.sbr

     文件     157235  2012-01-13 14:25  Edge_detectionDebugEdge_detectionView.obj

     文件          0  2012-01-13 14:25  Edge_detectionDebugEdge_detectionView.sbr

     文件      34822  2012-01-13 08:39  Edge_detectionDebugMainFrm.obj

     文件          0  2012-01-13 08:39  Edge_detectionDebugMainFrm.sbr

     文件         60  2012-01-13 14:25  Edge_detectionDebugmt.dep

     文件      69339  2012-01-13 08:49  Edge_detectionDebugSegApi.obj

     文件          0  2012-01-13 08:49  Edge_detectionDebugSegApi.sbr

     文件     465843  2012-01-13 08:39  Edge_detectionDebugStdAfx.obj

     文件    3360358  2012-01-13 08:39  Edge_detectionDebugStdAfx.sbr

     文件      23818  2012-01-13 08:39  Edge_detectionDebug exture.obj

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)