Click here to Skip to main content
15,896,063 members
Articles / Desktop Programming / MFC

Convolution of Bitmaps

Rate me:
Please Sign up or sign in to vote.
4.07/5 (27 votes)
29 Mar 20063 min read 214.8K   2.4K   44  
Article discussing how to convolve images, specificially the convolution of bitmaps.
// ImageConvolutionView.h : interface of the CImageConvolutionView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_IMAGECONVOLUTIONVIEW_H__4B554328_1B29_4E24_9A47_1497402C76A1__INCLUDED_)
#define AFX_IMAGECONVOLUTIONVIEW_H__4B554328_1B29_4E24_9A47_1497402C76A1__INCLUDED_

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

#include "ImageConvolutionDoc.h"

class CImageConvolutionView : public CView
{
protected: // create from serialization only
	CImageConvolutionView();
	DECLARE_DYNCREATE(CImageConvolutionView)

// Attributes
public:
	CImageConvolutionDoc* GetDocument();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CImageConvolutionView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	//}}AFX_VIRTUAL

// Implementation
public:
	COLORREF Convolve(CDC* dc, int sourcex, int sourcey, float kernel[3][3], int nBias,BOOL bGrayscale=FALSE);
	void ConvolveImage(float kernel[3][3], int nBias);
	virtual ~CImageConvolutionView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	float m_kernel[3][3];
	int m_nBias;
	//{{AFX_MSG(CImageConvolutionView)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in ImageConvolutionView.cpp
inline CImageConvolutionDoc* CImageConvolutionView::GetDocument()
   { return (CImageConvolutionDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

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

#endif // !defined(AFX_IMAGECONVOLUTIONVIEW_H__4B554328_1B29_4E24_9A47_1497402C76A1__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Programming using MFC and ATL for almost 12 years now. Currently studying Operating System implementation as well as Image processing. Previously worked on DSP and the use of FFT for audio application. Programmed using ADO, ODBC, ATL, COM, MFC for shell interfacing, databasing tasks, Internet items, and customization programs.

Comments and Discussions