文档章节

bmp位图保存方法、灰度拉伸、直方图均衡化和水波纹模拟

Ne0o0
 Ne0o0
发布于 2016/04/26 11:34
字数 2942
阅读 15
收藏 0
#if !defined(AFX_WAVEDLG_H__3AD6300B_435E_4773_8C88_DDE56BEE2A52__INCLUDED_)
#define AFX_WAVEDLG_H__3AD6300B_435E_4773_8C88_DDE56BEE2A52__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CWaveDlg dialog

class CWaveDlg : public CDialog
{
// Construction
public:
CWaveDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
//{{AFX_DATA(CWaveDlg)
enum { IDD = IDD_WAVE_DIALOG };
CSliderCtrl	m_slider2;
CSliderCtrl	m_sliderCtr;
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWaveDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
//}}AFX_VIRTUAL


// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CWaveDlg)

virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnStaticWave();
afx_msg void OnButtonTest();
afx_msg void OnDestroy();

afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnCancelMode();
afx_msg void OnTimer(UINT nIDEvent);
virtual void OnOK();
afx_msg void OnButton2();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnMenuitemRgbToGray();

afx_msg void OnMenuitemOrgImag();
afx_msg void OnMenuitemBinary();
afx_msg void OnButtonScrollWnd();
afx_msg void OnMenuitemInvertY();
afx_msg void OnMenuitemInvertX();
afx_msg void OnMenuitemHisto();
afx_msg void OnMenuitemSaveGray8bit();
afx_msg void OnMenuitemSaveBinaryBmp1bit();
afx_msg void OnMenuitemGlobGrayStretch();
afx_msg void OnMenuitemHistoEqualization();

//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
double m_dbPercent;
byte m_bBrightness;
int m_nPoolWid;
int m_nPoolHei;
CBitmap m_bmp,m_newBmp;
int * m_pPoolBuff,*m_pPoolBuff1;
byte *m_pImageDateBuff,*m_pImageDateBuff1;
CDC* m_pDC;
double GetDistance(const CPoint & p1,const CPoint &p2);
int GetAmplitude(int a0,int a1,int a2,int a3,int a4);
int GetEnergyFromWaterSourece(const CPoint &ptCenter,const CPoint &pt,double radius,int energy=50);
    CBrush m_brush;
void Shocking();
void RefreshImag(void);
void AdjustContrastAndBrightness(void);//调节对比度亮度
INT m_nCount;

void LimitMaxMin(byte& val)
{
if (val>255)
{
val =255;
}
if (val<0)
{
val= 0;
}
}

void AvgChannels(int & r,int &g,int &b);
void AdjustSimpleContrastAndBrightness(void);//调节对比度亮度
void Rgb2Gray24(int typeFlag);
void Gray2Binary(byte* imageBuffer,byte threshold);
void SaveBmp(void);
    void SaveBmpSingle(void);//8bit单色位图
    void SaveBmpBinary(void);//1bit单色位图
void InvertBuffer(INT direction);
void RoateImag(CPoint & roatePos,double roateAngle);
void GetHistogram(int *Histo);
void DrawHistoGram(int *Histo);
    void Rgb2Gray8(void);
void Rgb2Gray16(void);
void Rgb2Rgb8(void);
void Rgb2Rgb16(void);
void GlobGrayStrench();//全局灰度直方图拉伸
    void HistogramEqualization(void);//直方图均衡化
    void CalculateCDF(double *p);//计算累计分布函数
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_WAVEDLG_H__3AD6300B_435E_4773_8C88_DDE56BEE2A52__INCLUDED_)


////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Wave.h"
#include "WaveDlg.h"
#include<MATH.H>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CWaveDlg::CWaveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWaveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWaveDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_dbPercent=0.0;
m_nCount=1;
int len=6;
while (len--)
{
int a=len;
}
}

void CWaveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWaveDlg)
DDX_Control(pDX, IDC_SLIDER2, m_slider2);
DDX_Control(pDX, IDC_SLIDER, m_sliderCtr);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CWaveDlg, CDialog)
//{{AFX_MSG_MAP(CWaveDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_STATIC_WAVE, OnStaticWave)
ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
ON_WM_CANCELMODE()
ON_WM_TIMER()

ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_HSCROLL()
ON_COMMAND(ID_MENUITEM_RGB_TO_GRAY, OnMenuitemRgbToGray)
ON_COMMAND(ID_MENUITEM_ORG_IMAG, OnMenuitemOrgImag)
ON_COMMAND(ID_MENUITEM_BINARY, OnMenuitemBinary)
ON_BN_CLICKED(IDC_BUTTON_SCROLL_WND, OnButtonScrollWnd)
ON_COMMAND(ID_MENUITEM_INVERT_Y, OnMenuitemInvertY)
ON_COMMAND(ID_MENUITEM_INVERT_X, OnMenuitemInvertX)

ON_COMMAND(ID_MENUITEM_HISTO, OnMenuitemHisto)
ON_COMMAND(ID_MENUITEM_SAVE_GRAY_8BIT, OnMenuitemSaveGray8bit)
ON_COMMAND(ID_MENUITEM_SAVE_BINARY_BMP_1BIT, OnMenuitemSaveBinaryBmp1bit)
ON_COMMAND(ID_MENUITEM_GLOB_GRAY_STRETCH, OnMenuitemGlobGrayStretch)
ON_COMMAND(ID_MENUITEM_HISTO_EQUALIZATION, OnMenuitemHistoEqualization)
//}}AFX_MSG_MAP