数学形态学处理程序实例Word文档格式.docx

上传人:b****5 文档编号:15693853 上传时间:2022-11-15 格式:DOCX 页数:32 大小:27.56KB
下载 相关 举报
数学形态学处理程序实例Word文档格式.docx_第1页
第1页 / 共32页
数学形态学处理程序实例Word文档格式.docx_第2页
第2页 / 共32页
数学形态学处理程序实例Word文档格式.docx_第3页
第3页 / 共32页
数学形态学处理程序实例Word文档格式.docx_第4页
第4页 / 共32页
数学形态学处理程序实例Word文档格式.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

数学形态学处理程序实例Word文档格式.docx

《数学形态学处理程序实例Word文档格式.docx》由会员分享,可在线阅读,更多相关《数学形态学处理程序实例Word文档格式.docx(32页珍藏版)》请在冰豆网上搜索。

数学形态学处理程序实例Word文档格式.docx

BEGIN_MESSAGE_MAP(CJEFFView,CScrollView)

//{{AFX_MSG_MAP(CJEFFView)

ON_COMMAND(ID_EROSION,OnErosion)

ON_COMMAND(ID_DILATION,OnDilation)

ON_COMMAND(ID_OPEN,OnOpen)

ON_COMMAND(ID_CLOSE,OnClose)

ON_COMMAND(ID_ZAOSHENG,OnZaosheng)

ON_COMMAND(ID_BIANYUAN,OnBianyuan)

ON_COMMAND(ID_1,On1)

ON_COMMAND(ID_2,On2)

ON_COMMAND(ID_4,On4)

ON_COMMAND(ID_8,On8)

ON_COMMAND(ID_DILATION2,OnDilation2)

ON_COMMAND(ID_EROSION2,OnErosion2)

ON_COMMAND(ID_OPEN2,OnOpen2)

ON_COMMAND(ID_CLOSE2,OnClose2)

ON_COMMAND(ID_SMOOTH,OnSmooth)

ON_COMMAND(ID_RELOAD,OnReload)

ON_COMMAND(ID_TIDU,OnTidu)

ON_COMMAND(ID_BIANYUAN_H,OnBianyuanH)

ON_COMMAND(ID_QUSE,OnQuse)

ON_WM_LBUTTONDOWN()

//}}AFX_MSG_MAP

//Standardprintingcommands

ON_COMMAND(ID_FILE_PRINT,CScrollView:

:

OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_DIRECT,CScrollView:

ON_COMMAND(ID_FILE_PRINT_PREVIEW,CScrollView:

OnFilePrintPreview)

END_MESSAGE_MAP()

//CJEFFViewconstruction/destruction

CJEFFView:

CJEFFView()

{

//TODO:

addconstructioncodehere

ValidDoc=FALSE;

m_i=1;

}

~CJEFFView()

BOOLCJEFFView:

PreCreateWindow(CREATESTRUCT&

cs)

ModifytheWindowclassorstylesherebymodifying

//theCREATESTRUCTcs

returnCScrollView:

PreCreateWindow(cs);

//CJEFFViewdrawing

voidCJEFFView:

OnDraw(CDC*pDC)

CJEFFDoc*pDoc=GetDocument();

ASSERT_VALID(pDoc);

adddrawcodefornativedatahere

if(pDoc->

lpBitmap)

{

ValidDoc=TRUE;

nWidth=pDoc->

nWidth;

nHeight=pDoc->

nHeight;

lpBits=pDoc->

lpBits;

lpPoints=pDoc->

lpPoints;

BITMAPINFOHEADERbmi;

bmi.biSize=sizeof(BITMAPINFOHEADER);

bmi.biWidth=nWidth;

bmi.biHeight=nHeight;

bmi.biPlanes=1;

bmi.biBitCount=24;

bmi.biCompression=BI_RGB;

bmi.biSizeImage=0;

bmi.biXPelsPerMeter=0;

bmi.biYPelsPerMeter=0;

bmi.biClrUsed=0;

bmi.biClrImportant=0;

StretchDIBits(pDC->

m_hDC,0,0,nWidth*m_i,nHeight*m_i,0,0,nWidth,nHeight,

lpBits,

(BITMAPINFO*)&

bmi,

DIB_RGB_COLORS,

SRCCOPY);

}

OnInitialUpdate()

CScrollView:

OnInitialUpdate();

CSizesizeTotal;

calculatethetotalsizeofthisview

sizeTotal.cx=2000;

sizeTotal.cy=1700;

SetScrollSizes(MM_TEXT,sizeTotal);

//CJEFFViewprinting

OnPreparePrinting(CPrintInfo*pInfo)

//defaultpreparation

returnDoPreparePrinting(pInfo);

OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

addextrainitializationbeforeprinting

OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

addcleanupafterprinting

//CJEFFViewdiagnostics

AssertValid()const

AssertValid();

Dump(CDumpContext&

dc)const

Dump(dc);

CJEFFDoc*CJEFFView:

GetDocument()//non-debugversionisinline

ASSERT(m_pDocument->

IsKindOf(RUNTIME_CLASS(CJEFFDoc)));

return(CJEFFDoc*)m_pDocument;

#endif//_DEBUG

//CJEFFViewmessagehandlers

//二值形态学:

腐蚀

OnErosion()

int*lpMarks=newint[nWidth*nHeight];

intx,y,x1,y1;

intcount;

//中间变量

for(y=1;

y<

nHeight-1;

y++)

for(x=1;

x<

nWidth-1;

x++)

{

count=1;

for(y1=-1;

y1<

2;

y1++)

{

for(x1=-1;

x1<

x1++)

{

if(Out(x+x1,y+y1))//以(x,y)为中心的九个点是否有白色的像素点

count=0;

//如果有count=0,否则count=1;

}

}

if(count)lpMarks[x+y*nWidth]=1;

//黑色像素点记为1

elselpMarks[x+y*nWidth]=0;

//白色像素点记为0

}

if(lpMarks[x+y*nWidth]==0)Out(x,y)=255;

//白色像素点灰度为255

deletelpMarks;

//释放内存

GetDocument()->

PutPoint();

Invalidate();

膨胀

OnDilation()

count=0;

if(Out(x+x1,y+y1)==0)//以(x,y)为中心的九个点是否有黑色的像素点

count=1;

//若有记为一

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1