• 大小: 16KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: C/C++
  • 标签: 腐蚀膨胀  

资源简介

C语言编写的腐蚀膨胀开闭运算算法,比较简单,适合入门

资源截图

代码片段和文件信息

//////////////////////////////////////////////////////////////
//Name:morph.c
//Purpose: To perform morphological operation
//Author: phoenix CS TshingHua Beijing P.R.C.
//Email: bjlufengjun@www.163.net or lufengjun@hotmail.com
//Date:April 3 1998

//header file
#include “bmp.h“
#include “memory.h“
#include “math.h“
#include “stdio.h“
//owner defined stack
typedef struct{
  HGLOBAL hMem;
     POINT *lpMyStack;
  LONG  ElementsNum;
  LONG  ptr;
  }MYSTACK;
//macro definition
#define WIDTHBYTES(i)    ((i+31)/32*4)
#define PI 3.1415926535
#define RADIAN(angle) ((angle)*PI/180.0) //convert angle to radian

//function declaration
int PASCAL WinMain (HANDLE HANDLE LPSTR int);
LRESULT CALLBACK MainWndProc(HWND  UINTWPARAM LPARAM);
BOOL LoadBmpFile (HWND hWndchar *BmpFileName);
BOOL Dilation(HWND hWndBOOL Hori);
BOOL Erosion(HWND hWndBOOL Hori);
BOOL MorphOpen(HWND hWndBOOL Hori);
BOOL MorphClose(HWND hWndBOOL Hori);
BOOL Thinning(HWND hWnd);
//global variable declaration
BITMAPFILEHEADER   bf;
BITMAPINFOHEADER   bi;
HPALETTE           hPalette=NULL;
HBITMAP            hBitmap=NULL;
HGLOBAL            hImgData=NULL;
DWORD              NumColors;
DWORD              LineBytes;
HINSTANCE          ghInst;
DWORD              ImgWidth=0  ImgHeight=0;
///////////////////////////////////////////////////////////
int PASCAL WinMain (HANDLE hInstance HANDLE hPrevInstance
    LPSTR lpszCmdLine int nCmdShow)
{
MSG       msg;
WNDCLASS  wndclass;
HWND      hWnd;

ghInst=hInstance;
if ( ! hPrevInstance ){
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL IDC_ARROW);
wndclass.hbrBackground = GetStockobject (WHITE_BRUSH);
wndclass.lpszMenuName =  “BMPMENU“;
wndclass.lpszClassName = “phoenix ip system“;
    }

    if ( ! RegisterClass (&wndclass) )
return FALSE;
 
hWnd = CreateWindow (“phoenix ip system““Morphological operation“
 WS_OVERLAPPEDWINDOWCW_USEDEFAULTCW_USEDEFAULT
 CW_USEDEFAULT CW_USEDEFAULT NULLNULL
 hInstance NULL);
if (!hWnd)
return FALSE;
ShowWindow (hWnd SW_SHOWMAXIMIZED);
UpdateWindow (hWnd);

while ( GetMessage (&msg NULL 0 0) ){
TranslateMessage (&msg);
DispatchMessage (&msg);
    }

return msg.wParam;
}
////////////////////////////////////////////////////////////////
LRESULT CALLBACK MainWndProc(HWND hWnd UINT messageWPARAM wParam LPARAM lParam)
{
    static  HDC    hDChMemDC;
    PAINTSTRUCT    ps;

    switch (message){
    case WM_PAINT:
{         
hDC = BeginPaint(hWnd &ps);
if (hBitmap)

hMemDC = CreateCompatibleDC(hDC);
if (hPalette)
{           
SelectPalette (hDC hPalette FALSE); 
SelectPalette (hMemDC hPalette 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         547  1998-04-17 20:10  Bmp.h
     文件        1169  1998-04-17 20:10  Bmp.rc
     文件       28596  1998-04-21 09:37  morph.c
     文件       29696  1998-04-21 14:34  morph.exe
     文件         155  2000-06-11 09:44  readme.txt

评论

共有 条评论

相关资源