📄 photostarview.cpp
字号:
furiour.m_filtertype=1;
furiour.m_pImageObject=m_pImageObject;
furiour.OnFfuriour();
m_pImageObject->Height=furiour.nNewHeight;
m_pImageObject->Width=furiour.nNewWidth;
m_pImageObject->OnChangeImageSize();
CSize sizeTotal;
sizeTotal.cx =furiour.nNewWidth;
sizeTotal.cy =furiour.nNewHeight;
SetScrollSizes (MM_TEXT, sizeTotal);
CChildFrame *pChild = (CChildFrame *) GetParentFrame();
pChild->m_nWidth =furiour.nNewHeight;
pChild->m_nHeight =furiour.nNewHeight;
pChild->SetWindowPos( NULL , 0, 0, 2500, 2500, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnEnhanceUntifft()
{
CFfuriour furiour;
if(m_flag==1)
{
AfxMessageBox("请先进行傅立叶变换");
return ;
}
furiour.m_pImageObject=m_pImageObject;
furiour.m_translatetype=2;
furiour.m_filtertype=1;
m_flag=1;
furiour.OnFfuriour();
m_pImageObject->Height=furiour.iHeight;
m_pImageObject->Width=furiour.iWidth;
m_pImageObject->OnChangeImageSize();
CSize sizeTotal;
sizeTotal.cx =furiour.iWidth;
sizeTotal.cy =furiour.iHeight;
SetScrollSizes (MM_TEXT, sizeTotal);
CChildFrame *pChild = (CChildFrame *) GetParentFrame();
pChild->m_nWidth =furiour.iHeight;
pChild->m_nHeight =furiour.iHeight;
pChild->SetWindowPos( NULL , 0, 0, 2500, 2500, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnIdeallowfilter()
{
int nNewWidth = m_pImageObject->GetWidth();
int nNewHeight = m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="理想低通滤波";
frequency.m_iltem2="请输入截止频率的值";
frequency.m_mincutevalue=0;
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
frequency.m_pImageObject=m_pImageObject;
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.m_translatetype=1;
furiour.m_filtertype=1;
furiour.OnFfuriour();
furiour.OnIdealLowFilter();
furiour.m_translatetype=2;
furiour.OnFfuriour();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnIdealhightfilter()
{
int nNewWidth = m_pImageObject->GetWidth();
int nNewHeight = m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="理想高通滤波";
frequency.m_iltem2="请输入截止频率的值";
frequency.m_mincutevalue=0;
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
frequency.m_pImageObject=m_pImageObject;
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.m_translatetype=1;
furiour.m_filtertype=1;
furiour.OnFfuriour();
furiour.OnIdealHightFilter();
furiour.m_translatetype=2;
furiour.OnFfuriour();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnButworthhightfilter()
{
int nNewWidth = m_pImageObject->GetWidth();
int nNewHeight = m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="巴特沃思高通滤波";
frequency.m_iltem2="请输入截止频率的值";
frequency.m_mincutevalue=0;
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
frequency.m_pImageObject=m_pImageObject;
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.m_translatetype=1;
furiour.m_filtertype=1;
furiour.OnFfuriour();
furiour.OnButworthHightFilter();
furiour.m_translatetype=2;
furiour.OnFfuriour();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnButworthlowfilter()
{
int nNewWidth = m_pImageObject->GetWidth();
int nNewHeight = m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="巴特沃思低通滤波";
frequency.m_iltem2="请输入截止频率的值";
frequency.m_mincutevalue=0;
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
frequency.m_pImageObject=m_pImageObject;
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.m_translatetype=1;
furiour.m_filtertype=1;
furiour.OnFfuriour();
furiour.OnButworthLowFilter();
furiour.m_translatetype=2;
furiour.OnFfuriour();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnEnhanceRevercefilter()
{
int nNewHeight=m_pImageObject->GetWidth();
int nNewWidth=m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="逆滤波复原";
frequency.m_iltem2="请输入截止频率的值";
frequency.m_mincutevalue=0;
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.OnReverceFilter();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnEnhanceVenusfilter()
{
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem=" 维纳滤波";
frequency.m_iltem2="请输入常数K的值";
frequency.m_mincutevalue=0.001;
frequency.m_maxcutevalue=15;
if(frequency.DoModal()!=IDOK)
{
return;
}
furiour.m_k=frequency.m_frequencyvalue;
furiour.m_pImageObject=m_pImageObject;
furiour.OnVenusFliter();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnHomofilter()
{
int nNewWidth = m_pImageObject->GetWidth();
int nNewHeight = m_pImageObject->GetHeight();
CFrequencyFilterDlg frequency;
CFfuriour furiour;
frequency.m_iltem="同态滤波";
frequency.m_maxcutevalue=(int)sqrt(pow(nNewWidth/2,2)+pow(nNewHeight /2,2));
if(frequency.DoModal()!=IDOK)
{
return;
}
furiour.m_pImageObject=m_pImageObject;
furiour.m_cutevalue=frequency.m_frequencyvalue;
furiour.m_translatetype=1;
furiour.m_filtertype=2;
furiour.OnFfuriour();
furiour.OnHomoFilter();
furiour.m_translatetype=2;
furiour.m_filtertype=2;
furiour.OnFfuriour();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnPeppersaltnoise()
{
CFfuriour furiour;
furiour.m_pImageObject=m_pImageObject;
furiour.OnPepperSaltNoise();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnGussnoise()
{
CFfuriour furiour;
furiour.m_pImageObject=m_pImageObject;
furiour.OnGussNoise();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnEnhanceLinerfilterdlg()
{
CLinerFilterDlg liner;
if(liner.DoModal()!=IDOK)
{
return;
}
int m_iWinSize=liner.m_size;
CFilter filter(m_pImageObject,m_iWinSize);
UpdateData(true);
filter.m_piTemplate=new double[m_iWinSize*m_iWinSize];
for(int i=0;i<m_iWinSize*m_iWinSize;i++)
{
filter.m_piTemplate[i]=0;
}
if (m_iWinSize==3)
{
filter.m_piTemplate[0]=liner.m_worth22;
filter.m_piTemplate[1]=liner.m_worth23;
filter.m_piTemplate[2]=liner.m_worth24;
filter.m_piTemplate[3]=liner.m_worth32;
filter.m_piTemplate[4]=liner.m_worth33;
filter.m_piTemplate[5]=liner.m_worth34;
filter.m_piTemplate[6]=liner.m_worth42;
filter.m_piTemplate[7]=liner.m_worth43;
filter.m_piTemplate[8]=liner.m_worth44;
}
else
{
if (m_iWinSize==5)
{
filter.m_piTemplate[0]=liner.m_worth11;
filter.m_piTemplate[1]=liner.m_worth12;
filter.m_piTemplate[2]=liner.m_worth13;
filter.m_piTemplate[3]=liner.m_worth14;
filter.m_piTemplate[4]=liner.m_worth15;
filter.m_piTemplate[5]=liner.m_worth21;
filter.m_piTemplate[6]=liner.m_worth22;
filter.m_piTemplate[7]=liner.m_worth23;
filter.m_piTemplate[8]=liner.m_worth24;
filter.m_piTemplate[9]=liner.m_worth25;
filter.m_piTemplate[10]=liner.m_worth31;
filter.m_piTemplate[11]=liner.m_worth32;
filter.m_piTemplate[12]=liner.m_worth33;
filter.m_piTemplate[13]=liner.m_worth34;
filter.m_piTemplate[14]=liner.m_worth35;
filter.m_piTemplate[15]=liner.m_worth41;
filter.m_piTemplate[16]=liner.m_worth42;
filter.m_piTemplate[17]=liner.m_worth43;
filter.m_piTemplate[18]=liner.m_worth44;
filter.m_piTemplate[19]=liner.m_worth45;
filter.m_piTemplate[20]=liner.m_worth51;
filter.m_piTemplate[21]=liner.m_worth52;
filter.m_piTemplate[22]=liner.m_worth53;
filter.m_piTemplate[23]=liner.m_worth54;
filter.m_piTemplate[24]=liner.m_worth55;
}
}
filter.OnLinerFilter();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnEnhanceDegenration()
{
CFfuriour furiour;
furiour.m_pImageObject=m_pImageObject;
furiour.OnDegenerate();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnErosion()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_iltem=" 腐蚀运算";
if (morphology.DoModal()!=IDOK)
{
return;
}
morphology.m_morphologytype=1;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnDilation()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_iltem=" 膨胀运算";
if (morphology.DoModal()!=IDOK)
{
return;
}
morphology.m_morphologytype=2;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnOpen()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_iltem=" 开运算";
if (morphology.DoModal()!=IDOK)
{
return ;
}
morphology.m_morphologytype=3;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnClose()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_iltem=" 闭运算";
if (morphology.DoModal()!=IDOK)
{
return ;
}
morphology.m_morphologytype=4;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnThining()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_morphologytype=5;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnThicking()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_morphologytype=6;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnSkeleton()
{
CMorphology morphology;
morphology.m_pImageObject=m_pImageObject;
morphology.m_iltem=" 骨骼化运算";
if (morphology.DoModal()!=IDOK)
{
return ;
}
morphology.m_morphologytype=7;
morphology.OnMorphology();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnManualthreshold()
{
CThreshold threshold;
threshold.m_pImageObject=m_pImageObject;
if (threshold.DoModal()!=IDOK)
{
return;
}
threshold.OnManualThreshold();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnAutoworth()
{
CThreshold threshold;
threshold.m_pImageObject=m_pImageObject;
threshold.OnAutoThreshold();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow(); // TODO: Add your command handler code here
}
void CPhotoStarView::OnRegiongrowing()
{
CThreshold threshold;
threshold.m_pImageObject=m_pImageObject;
threshold.OnAreaGrowing();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnAreacombine()
{
CThreshold threshold;
threshold.m_pImageObject=m_pImageObject;
threshold.OnDivCom();
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnDownhillfilter()
{
// TODO: Add your command handler code here
CDownHill downhill;
downhill.m_pImageObject=m_pImageObject;
downhill.m_nStartX=m_nStartX;
downhill.m_nStartY=m_nStartY;
downhill.m_nEndX=m_nEndX;
downhill.m_nEndY=m_nEndY;
downhill.m_nlable2=1;
downhill.m_nlable=1;
clock_t timeStart,timeFinish;
//开始计时
timeStart=clock();
downhill.OnDownHill();
//计时结束
timeFinish=clock();
//转换时间,单位s
double timeElapsed=(double)(timeFinish-timeStart)/CLOCKS_PER_SEC;
CString str;
str.Format("用时:%.3f 秒",timeElapsed);
AfxMessageBox(str);
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnConstractAlgorithmOne()
{
CDownHill downhill;
downhill.m_pImageObject=m_pImageObject;
downhill.m_nStartX=m_nStartX;
downhill.m_nStartY=m_nStartY;
downhill.m_nEndX=m_nEndX;
downhill.m_nEndY=m_nEndY;
downhill.m_nlable2=1;
downhill.m_nlable=2;
clock_t timeStart,timeFinish;
//开始计时
timeStart=clock();
downhill.OnDownHill();
//计时结束
timeFinish=clock();
//转换时间,单位s
double timeElapsed=(double)(timeFinish-timeStart)/CLOCKS_PER_SEC;
CString str;
str.Format("用时:%.3f 秒",timeElapsed);
AfxMessageBox(str);
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
void CPhotoStarView::OnConstractAlgorithmTwo()
{
CDownHill downhill;
downhill.m_pImageObject=m_pImageObject;
downhill.m_nStartX=m_nStartX;
downhill.m_nStartY=m_nStartY;
downhill.m_nEndX=m_nEndX;
downhill.m_nEndY=m_nEndY;
downhill.m_nlable2=2;
downhill.m_nlable=3;
clock_t timeStart,timeFinish;
//开始计时
timeStart=clock();
downhill.OnDownHill();
//计时结束
timeFinish=clock();
//转换时间,单位s
double timeElapsed=(double)(timeFinish-timeStart)/CLOCKS_PER_SEC;
CString str;
str.Format("用时:%.3f 秒",timeElapsed);
AfxMessageBox(str);
//Update the window to display the filtered image
InvalidateRect(NULL);
UpdateWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -