资源简介
Watershed Algorithm(分水岭算法),就是根据分水岭的构成来考虑图像的分割。现实中我们可以想象有山有湖的景象,那么那一定是水绕山,山围水的情形。当然在需要的时候,要人工构筑分水岭,以防集水盆之间的互相穿透。而区分高山(plateaus)与水的界线,以及湖与湖之间的间隔或都是连通的关系,即为分水岭(watershed)。
代码片段和文件信息
// Imageobject.cpp: implementation of the CImageobject class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “Imageobject.h“
#include “ImageLoad.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE( CImageobject Cobject )
char *CImageobject::pszExtensions[] = { “.bmp“ “.gif“ “.pcx“ “.tga“ “.jpg“ “.tif“ ““ };
//////////////////////////////////////////////////
// Constructor and destructor
//
CImageobject::CImageobject()
{
m_nWidth = m_nHeight = m_nBits = m_nColors = m_nImageType = 0;
m_nX = m_nY = 0;
m_nLastError = 0;
m_hDib = NULL;
m_nPaletteCreationType = JGPT_FIXED_PALETTE;
m_pszFileName = NULL;
m_pLogPalette = NULL;
m_nQuality = 80;
m_pDib = NULL;
m_lBufSize = 0;
}
CImageobject::CImageobject( const char *pszFileName CDC *pDC int nX int nY )
{
m_nWidth = m_nHeight = m_nBits = m_nColors = m_nImageType = 0;
m_nX = m_nY = 0;
m_nLastError = 0;
m_hDib = NULL;
m_nPaletteCreationType = JGPT_FIXED_PALETTE;
m_pszFileName = NULL;
m_pLogPalette = NULL;
m_nQuality = 80;
m_pDib = NULL;
m_lBufSize = 0;
LoadFromFile( pszFileName pDC nX nY );
}
void CImageobject::operator=( const CImageobject &Imageobject )
{
DestroyImage();
m_nLastError = Imageobject.m_nLastError;
m_nWidth = Imageobject.m_nWidth;
m_nHeight = Imageobject.m_nHeight;
m_nPlanes = Imageobject.m_nPlanes;
m_nBits = Imageobject.m_nBits;
m_nColors = Imageobject.m_nColors;
m_nImageType = Imageobject.m_nImageType;
m_nX = Imageobject.m_nX;
m_nY = Imageobject.m_nY;
m_nScreenPlanes = Imageobject.m_nScreenPlanes;
m_nScreenBits = Imageobject.m_nScreenBits;
m_nPaletteInBytes = Imageobject.m_nPaletteInBytes;
m_nQuality = Imageobject.m_nQuality;
m_nPaletteCreationType = Imageobject.m_nPaletteCreationType;
int nNumColors = m_nColors;
int nWidthBytes = GetWidthInBytes( m_nBits m_nWidth );
if( Imageobject.m_hDib != NULL )
{
DWORD dwSize = ::GlobalSize( Imageobject.m_hDib );
char *pData = ( char * )::GlobalLock( Imageobject.m_hDib );
if( pData != NULL )
{
HGLOBAL hGlobal = ::GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT dwSize );
if( hGlobal != NULL )
{
char *pDestData = ( char * )::GlobalLock( hGlobal );
if( pDestData != NULL )
{
memcpy( pDestData pData dwSize );
if( nNumColors != 0 )
CreatePaletteFromDIB( ( RGBQUAD * )&pData[sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)] nNumColors );
else if( Imageobject.m_pLogPalette != NULL )
{
m_pLogPalette = (LOGPALETTE *) new char[ sizeof( LOGPALETTE ) + Imageobject.m_pLogPalette->palNumEntries * sizeof( PALETTEENTRY ) ];
if( m_pLogPalette != NULL )
{
for( int i=0; iject.m_pLogPalette->palNumEntries; i++ )
m_pLogPalette[i] = Imageobject.m_pLogPalette[i];
m_Palette.CreatePalett
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 741 1999-09-21 14:31 WaterShed\ImageErrors.h
文件 3904 1999-09-22 11:12 WaterShed\Imageload.h
文件 15566 1997-03-26 12:15 WaterShed\ImageLoad.lib
文件 60290 2004-06-05 17:20 WaterShed\Imageob
文件 7435 2004-06-05 17:20 WaterShed\Imageob
文件 2508 2008-05-20 14:21 WaterShed\MainFrm.cpp
文件 1639 2008-05-19 23:34 WaterShed\MainFrm.h
文件 14223 2008-05-19 23:39 WaterShed\MyMath.cpp
文件 3392 2008-05-20 13:18 WaterShed\MyMath.h
文件 4383 2008-05-19 22:08 WaterShed\ReadMe.txt
文件 688 2008-05-20 13:47 WaterShed\Resource.h
文件 211 2008-05-19 22:08 WaterShed\StdAfx.cpp
文件 1054 2008-05-19 22:08 WaterShed\StdAfx.h
文件 47980 2007-05-04 11:59 WaterShed\WaterShed.aps
文件 2328 2007-05-04 12:11 WaterShed\WaterShed.clw
文件 4263 2008-05-19 22:08 WaterShed\WaterShed.cpp
文件 4984 2008-05-20 13:47 WaterShed\WaterShed.dsp
文件 543 2008-05-22 16:18 WaterShed\WaterShed.dsw
文件 1389 2008-05-19 22:08 WaterShed\WaterShed.h
文件 197632 2007-05-04 12:11 WaterShed\WaterShed.ncb
文件 52736 2007-05-04 12:11 WaterShed\WaterShed.opt
文件 2402 2007-05-04 12:09 WaterShed\WaterShed.plg
文件 11791 2007-05-04 11:59 WaterShed\WaterShed.rc
文件 33129 2007-04-29 10:40 WaterShed\WaterShedDoc.cpp
文件 3192 2008-05-20 15:05 WaterShed\WaterShedDoc.h
文件 4305 2008-05-19 23:53 WaterShed\WaterShedView.cpp
文件 2222 2008-05-19 22:22 WaterShed\WaterShedView.h
文件 94678 2004-05-29 19:32 WaterShed\res\bitmap3.bmp
文件 3638 2008-05-20 13:47 WaterShed\res\demo.ico
..A.SH. 12288 2007-04-29 16:44 WaterShed\res\Thumbs.db
............此处省略42个文件信息
评论
共有 条评论