00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "stdafx.h"
00016
00017 #include <cfl/resource.h>
00018
00019 #include <Camera/InterfaceDll.h>
00020
00021 #include <cfl/ScanFilterMedian.h>
00022 #include <cfl/FilterDlg_Median.h>
00023 #include <cfl/ToolCilImage.h>
00024
00025 #include <cil/MedianImageFilter.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifdef _DEBUG
00038 #undef THIS_FILE
00039 static char THIS_FILE[]=__FILE__;
00040 #define new DEBUG_NEW
00041 #endif
00042
00043
00044
00045
00046 #ifdef CIL_MedianImageFilter_USE_TYPE_HACK // ::Type hack
00047 typedef cil::MedianImageFilter< Image >::Type MedianFilterType;
00048 #else
00049 typedef cil::MedianImageFilter< Image > MedianFilterType;
00050 #endif
00051
00052 #define CFL_SCHEMAVERSION_FILTERMEDIAN 0
00053 // this filter's name
00054 LPCTSTR CScanFilterMedian::m_lpcsFilterName = _T("Median");
00055
00056 LPCTSTR CScanFilterMedian::m_lpcsShortFilterName = CScanFilterMedian::m_lpcsFilterName;
00057
00058 IMPLEMENT_SERIAL(CScanFilterMedian, CScanFilterRank, CFL_SCHEMAVERSION_FILTERMEDIAN)
00059
00060
00061
00062
00063
00064 CScanFilterMedian::CScanFilterMedian()
00065 {
00066
00067
00068 m_csFilterName = m_lpcsFilterName;
00069
00070 ReadFilterSettings();
00071 }
00072
00073
00074
00075
00076
00077 BOOL CScanFilterMedian::RunModeless( CWnd* pParentWnd, CDocument* pDoc )
00078 {
00079
00080
00081 CFilterDlg_MedianPtr pDlg = new CFilterDlg_Median();
00082
00083 if ( Q_INVALID( NULL == pDlg ) )
00084 return FALSE;
00085
00086 pDlg->SetParameters( this, pDoc );
00087
00088
00089
00090
00091
00092 pDlg->Create( IDD_FILTERDLG_MEDIAN, pParentWnd );
00093
00094 m_pDlg = pDlg;
00095
00096 BOOL bRet = Apply();
00097
00098 if ( bRet )
00099 {
00100 pDlg->UpdateView();
00101 }
00102
00103 return bRet;
00104 }
00105
00106
00107
00108
00109
00110
00111 BOOL CScanFilterMedian::Apply()
00112 {
00113
00114
00115 if ( Q_INVALID( NULL == m_lpsbIn ) )
00116 return FALSE;
00117
00118 if ( Q_INVALID( NULL == m_lpsbOut ) )
00119 return FALSE;
00120
00121 if ( Q_INVALID( false == m_lpsbIn->IsCompleteFrame() ) )
00122 return FALSE;
00123
00124
00125
00126
00127 Q_RETURN( m_lpsbOut->CreateOutputBufferFor( *m_lpsbIn ) );
00128
00129 m_lpsbOut->m_csBufferName.Format( _T("%s - %s %d,%d"), m_lpsbIn->m_csBufferName, m_lpcsShortFilterName, GetSizeX(), GetSizeY() );
00130
00131 if ( IsInteractive() )
00132 {
00133 m_pDlg->SetDlgItemText( IDC_BUFFEROUTNAME, m_lpsbOut->m_csBufferName );
00134 }
00135
00136
00137
00138
00139 MedianFilterType filter( ToRadius( m_cpSize.x, m_cpSize.y ) );
00140
00141 filter.Apply( ToImage( m_lpsbIn ), ToImage( m_lpsbOut ) );
00142
00143
00144
00145
00146 if ( m_lpsbIn->IsBidirectionalScan() && m_lpsbOut->IsBidirectionalScan() )
00147 {
00148 filter.Apply( ToImage( m_lpsbIn, true ), ToImage( m_lpsbOut, true ) );
00149 }
00150
00151 return TRUE;
00152 }
00153
00154
00155
00156