使用Matrix對圖像的旋轉(zhuǎn)、平移、翻轉(zhuǎn),代碼如下:
Matrix m_Matrix = new Matrix();
PointF[] imageDisplayPTs;//圖像的坐標(biāo)點(diǎn)對象數(shù)組
PointF changeCenterPoint = PointF.Empty;//圖像中心點(diǎn)
int nAngle=90;//角度
GraphicsPath gp = new GraphicsPath();
gp.AddPolygon(
new PointF[]
{ new PointF(0, 0),
new PointF(dcm.m_DataBmp.Width, 0),
new PointF(0, dcm.m_DataBmp.Height),
new PointF(dcm.m_DataBmp.Width, dcm.m_DataBmp.Height)});
gp.Transform(m_Matrix);
imageDisplayPTs = gp.PathPoints;
//獲取圖像中心點(diǎn)
changeCenterPoint = PointF.Empty;
changeCenterPoint.X = (imageDisplayPTs[0].X + imageDisplayPTs[3].X) / 2;
changeCenterPoint.Y = (imageDisplayPTs[0].Y + imageDisplayPTs[3].Y) / 2;
//旋轉(zhuǎn)
m_Matrix.RotateAt(nAngle, changeCenterPoint, MatrixOrder.Append);
//平移
m_Matrix.Translate(-changeCenterPoint.X, -changeCenterPoint.Y, MatrixOrder.Append);
//以Y軸翻轉(zhuǎn)
m_Matrix.Multiply(new Matrix(-1, 0, 0, 1, 0, 0), MatrixOrder.Append);
//以X軸翻轉(zhuǎn)
m_Matrix.Multiply(new Matrix(1, 0, 0, -1, 0, 0), MatrixOrder.Append);
Matrix類的操作內(nèi)容可參考:文章來源:http://www.zghlxwxcb.cn/news/detail-504264.html
C# Drawing.Drawing2D.Matrix類,二維矩陣幾何變換的3x3仿射矩陣類_wangnaisheng的博客-CSDN博客文章來源地址http://www.zghlxwxcb.cn/news/detail-504264.html
到了這里,關(guān)于C#使用Matrix類對Dicom圖像的旋轉(zhuǎn)、平移、翻轉(zhuǎn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!