图像处理中,纹理特征的提取部分代码如下//计算纹理特征voidCTextureDlg::OnBtnComputeTexture(){ doubledEnergy =0.0; doubledEntropy =0.0; doubledInertiaQuadrature=0.0; doubledLocalCalm =0.0; doubledCorrelation =0.0; doubledEnergy1 =0.0; doubledEntropy1 =0.0; doubledInertiaQuadrature1=0.0; doubledLocalCalm1 =0.0; doubledCorrelation1 =0.0; unsignedchar**arLocalImage; arLocalImage=cmatrix(0,m_grayShow.FilterWindowWidth-1,0,m_grayShow.FilterWindowWidth-1); introlltimeH=m_grayShow.ImageHeight/m_grayShow.FilterWindowWidth; introlltimeW=m_grayShow.ImageWidth/m_grayShow.FilterWindowWidth; inti,j; intp,q; //将图像分成若干个窗口,计算其纹理均值 for(i=0;i<rolltimeH;i++) { for(j=0;j<rolltimeW;j++) { //首先赋值给子窗口 for(p=0;p<m_grayShow.FilterWindowWidth;p++) { for(q=0;q<m_grayShow.FilterWindowWidth;q++) { arLocalImage[p][q]=m_grayShow.ImageArray[i*m_grayShow.FilterWindowWidth+p][j*m_grayShow.FilterWindowWidth+q]; } } m_grayShow.ComputeMatrix(arLocalImage,m_grayShow.FilterWindowWidth); m_grayShow.ComputeFeature(dEnergy1,dEntropy1,dInertiaQuadrature1,dCorrelation1,dLocalCalm1,m_grayShow.PMatrixH,m_grayShow.GrayLayerNum); dEnergy+=dEnergy1; dEntropy+=dEntropy1; dInertiaQuadrature+=dInertiaQuadrature1; dCorrelation+=dCorrelation1; dLocalCalm+=dLocalCalm1; } } dEnergy/=(rolltimeH*rolltimeW); dEntropy/=(rolltimeH*rolltimeW); dInertiaQuadrature/=(rolltimeH*rolltimeW); dCorrelation/=(rolltimeH*rolltimeW); dLocalCalm/=(rolltimeH*rolltimeW); m_dEnergy =dEnergy; m_dEntropy =dEntropy; m_dInertiaQuadrature=dInertiaQuadrature; m_dCorrelation =dCorrelation; m_dLocalCalm =dLocalCalm; UpdateData(false);}
2024/1/20 9:29:28
3.93MB
纹理
1