???個(gè)人主頁:Sarapines Programmer
???系列專欄:《圖形學(xué) | 圖像解碼》
?詩賦清音:云生高巔夢遠(yuǎn)游, 星光點(diǎn)綴碧海愁。 山川深邃情難晤, 劍氣凌云志自修。
?文章來源地址http://www.zghlxwxcb.cn/news/detail-804872.html
目錄
??1. 初識模式識別
??2.?圖形變換
??2.1 開發(fā)環(huán)境及實(shí)現(xiàn)
??2.2 實(shí)驗(yàn)?zāi)康?/p>
??2.3 實(shí)驗(yàn)要求
??2.4 實(shí)驗(yàn)原理
??2.5 實(shí)驗(yàn)步驟
??2.5.1?平移變換
??2.5.2?旋轉(zhuǎn)變換
??2.5.3?對稱變換
??2.5.4?比例變換
??2.4 研究體會
??總結(jié)
??1. 初識模式識別
圖形學(xué)技術(shù)是一門涉及計(jì)算機(jī)圖形和圖像處理的學(xué)科,其目標(biāo)是通過算法和數(shù)學(xué)模型來創(chuàng)建、處理和呈現(xiàn)圖形和圖像。這項(xiàng)技術(shù)的應(yīng)用范圍非常廣泛,涵蓋了許多領(lǐng)域,包括計(jì)算機(jī)游戲、虛擬現(xiàn)實(shí)、計(jì)算機(jī)輔助設(shè)計(jì)(CAD)、醫(yī)學(xué)圖像處理、動畫制作等。
以下是圖形學(xué)技術(shù)的一些關(guān)鍵方面:
圖形生成和渲染: 圖形學(xué)技術(shù)用于生成和呈現(xiàn)視覺圖像。這包括三維圖形的創(chuàng)建、光照、陰影、顏色和紋理等方面的處理,以產(chǎn)生逼真的圖形。
計(jì)算機(jī)輔助設(shè)計(jì)(CAD): 在工程學(xué)和設(shè)計(jì)領(lǐng)域,圖形學(xué)技術(shù)被廣泛用于創(chuàng)建和編輯數(shù)字化的設(shè)計(jì)圖紙,促進(jìn)設(shè)計(jì)過程的可視化和交互。
計(jì)算機(jī)游戲和虛擬現(xiàn)實(shí): 圖形學(xué)技術(shù)是游戲開發(fā)和虛擬現(xiàn)實(shí)領(lǐng)域的核心。它用于創(chuàng)建游戲中的角色、場景、特效以及虛擬現(xiàn)實(shí)環(huán)境,提供沉浸式的視覺體驗(yàn)。
醫(yī)學(xué)圖像處理: 在醫(yī)學(xué)領(lǐng)域,圖形學(xué)技術(shù)被用于處理和呈現(xiàn)醫(yī)學(xué)圖像,如CT掃描、MRI等,以協(xié)助醫(yī)生進(jìn)行診斷和手術(shù)規(guī)劃。
動畫制作: 圖形學(xué)技術(shù)是制作動畫的關(guān)鍵。通過在計(jì)算機(jī)上生成圖形幀并進(jìn)行渲染,動畫制作得以實(shí)現(xiàn)。
圖像處理: 圖形學(xué)技術(shù)也包括對靜態(tài)圖像的處理,如圖像編輯、濾鏡應(yīng)用、圖像合成等。
在圖形學(xué)技術(shù)的發(fā)展中,硬件加速、實(shí)時(shí)渲染、虛擬現(xiàn)實(shí)和增強(qiáng)現(xiàn)實(shí)等方面的創(chuàng)新不斷推動著圖形學(xué)的前沿。這門技術(shù)為數(shù)字世界的可視化和交互提供了強(qiáng)大的工具和方法。
??2.?圖形變換
??2.1 開發(fā)環(huán)境及實(shí)現(xiàn)
- 語言: C++
- 平臺: Microsoft Visual Studio 2022
??2.2 實(shí)驗(yàn)?zāi)康?/strong>
- 進(jìn)行二維圖形的各種幾何變換,利用基本圖形實(shí)現(xiàn)。
??2.3 實(shí)驗(yàn)要求
- 使用Microsoft Visual Studio 2022編程。
- 實(shí)現(xiàn)以下幾何變換:
- 平移變換
- 旋轉(zhuǎn)變換
- 對稱變換
- 比例變換。
??2.4 實(shí)驗(yàn)原理
圖形的幾何變換一般是指對圖形的幾何信息經(jīng)過變換后產(chǎn)生新的圖形,圖形幾何變換既可以看作是坐標(biāo)系不動而圖形變動,變動后的圖形在坐標(biāo)系中的坐標(biāo)值發(fā)生變化;出可以看作圖形不動而坐標(biāo)系變動,變動后的圖形在新坐標(biāo)系下具有新的坐標(biāo)值。這兩種情況本質(zhì)上都是一樣的,都是圖形由新的坐標(biāo)值表示,因此是新產(chǎn)生的圖形。圖形幾何變換包括比例變換、對稱變換、錯(cuò)切變換、旋轉(zhuǎn)變換、平移變換及其復(fù)合變換。圖形上所有的點(diǎn)在幾何變換前后的坐標(biāo)關(guān)系一般用解析幾何方法可以求得,但這些幾何關(guān)系用矩陣方法表示,運(yùn)算更為方便。
圖形基本幾何變換是指比例變換、對稱變換、錯(cuò)切變換、旋轉(zhuǎn)變換和平移變換等。除平移變換外,這里其它四種幾何變換都可以用組成圖形的點(diǎn)向量(或稱1×2階矩陣)和2×2階變換矩陣相乘表示,而平移變換需引入新方法來實(shí)現(xiàn)。
??2.5 實(shí)驗(yàn)步驟
對圖形分別進(jìn)行平移變換、旋轉(zhuǎn)變換、對稱變換以及比例變換。
程序代碼示例如下:
??2.5.1?平移變換
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
GLsizei winWidth = 600, winHeight = 600;
GLfloat xwcMin = 0.0, xwcMax = 225.0;
GLfloat ywcMin = 0.0, ywcMax = 225.0;
class wcPt2D
{
public:
GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.14159;
void Init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
}
void Matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
GLint row, col;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matIdent3x3[row][col] = (row == col);
}
}
}
void Matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
GLint row, col;
Matrix3x3 matTemp;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matTemp[row][col] =
m1[row][0] * m2[0][col] +
m1[row][1] * m2[1][col] +
m1[row][2] * m2[2][col];
}
}
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
m2[row][col] = matTemp[row][col];
}
}
}
void Translate2D(GLfloat tx, GLfloat ty)
{
Matrix3x3 matTransl;
Matrix3x3SetIdentity(matTransl);
matTransl[0][2] = tx;
matTransl[1][2] = ty;
Matrix3x3PreMultiply(matTransl, matComposite);
}
void TransformVerts2D(GLint nVerts, wcPt2D* verts)//平移函數(shù)實(shí)現(xiàn)
{
GLint k;
GLfloat temp;
for (k = 0; k < nVerts; k++)
{
temp = matComposite[0][0] * verts[k].x +
matComposite[0][1] * verts[k].y +
matComposite[0][2];
verts[k].y = matComposite[1][0] * verts[k].x +
matComposite[1][1] * verts[k].y +
matComposite[1][2];
verts[k].x = temp;
}
}
void Trangle(wcPt2D* verts)
{
GLint k;
glBegin(GL_TRIANGLES);
for (k = 0; k < 3; k++)
{
glVertex2f(verts[k].x, verts[k].y);
}
glEnd();
}
void WinReshapFcn(GLint newWidth, GLint newHeight)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(xwcMin, xwcMax, ywcMin, ywcMax);
glClear(GL_COLOR_BUFFER_BIT);
}
void DisplayFcn()
{
glClear(GL_COLOR_BUFFER_BIT);
GLint nVerts = 3;
wcPt2D verts[3] = { {50,25},{150,25 },{100,100} };
wcPt2D centroidPt;
GLint k, xSum = 0, ySum = 0;
for (size_t k = 0; k < nVerts; k++)
{
xSum += verts[k].x;
ySum += verts[k].y;
}
centroidPt.x = GLfloat(xSum) / GLfloat(nVerts);
centroidPt.y = GLfloat(ySum) / GLfloat(nVerts);
wcPt2D pivPt, fixedPt;
pivPt = centroidPt;
fixedPt = centroidPt;
GLfloat tx = 0, ty = 100;
GLfloat sx = 0.5, sy = 0.5;
GLdouble theta = pi / 2;
glColor3f(0, 0, 1);
Trangle(verts);
Matrix3x3SetIdentity(matComposite);
Translate2D(tx, ty);
TransformVerts2D(nVerts, verts);//調(diào)用函數(shù)
glColor3f(1, 0, 0);
Trangle(verts);
glFlush();
}
void draw_pixel(int ix, int iy)
{
glBegin(GL_POINTS);
glVertex2i(ix, iy);
glEnd();
}
void myinit()
{
glClearColor(1.0, 0.8, 1.0, 1.0);
glColor3f(0.0, 0.5, 0.5);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 500);
glutInitWindowPosition(150.0, 150.0);
glutCreateWindow("圖像平移變換");
glutDisplayFunc(DisplayFcn);
glutReshapeFunc(WinReshapFcn);
myinit();
glutMainLoop();
}
運(yùn)行結(jié)果:
?
??2.5.2?旋轉(zhuǎn)變換
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
GLsizei winWidth = 600, winHeight = 600;
GLfloat xwcMin = 0.0, xwcMax = 225.0;
GLfloat ywcMin = 0.0, ywcMax = 225.0;
class wcPt2D
{
public:
GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.14159;
void Init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
}
void Matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
GLint row, col;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matIdent3x3[row][col] = (row == col);
}
}
}
void Matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
GLint row, col;
Matrix3x3 matTemp;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matTemp[row][col] =
m1[row][0] * m2[0][col] +
m1[row][1] * m2[1][col] +
m1[row][2] * m2[2][col];
}
}
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
m2[row][col] = matTemp[row][col];
}
}
}
void Translate2D(GLfloat tx, GLfloat ty)
{
Matrix3x3 matTransl;
Matrix3x3SetIdentity(matTransl);
matTransl[0][2] = tx;
matTransl[1][2] = ty;
Matrix3x3PreMultiply(matTransl, matComposite);
}
void Rotate2D(wcPt2D pivotPt, GLfloat theta)//旋轉(zhuǎn)
{
Matrix3x3 matRot;
Matrix3x3SetIdentity(matRot);
matRot[0][0] = cos(theta);
matRot[0][1] = -sin(theta);
matRot[0][2] = pivotPt.x * (1 - cos(theta)) +
pivotPt.y * sin(theta);
matRot[1][0] = sin(theta);
matRot[1][1] = cos(theta);
matRot[1][2] = pivotPt.y * (1 - cos(theta)) -
pivotPt.x * sin(theta);
Matrix3x3PreMultiply(matRot, matComposite);
}
void TransformVerts2D(GLint nVerts, wcPt2D* verts)//平移
{
GLint k;
GLfloat temp;
for (k = 0; k < nVerts; k++)
{
temp = matComposite[0][0] * verts[k].x +
matComposite[0][1] * verts[k].y +
matComposite[0][2];
verts[k].y = matComposite[1][0] * verts[k].x +
matComposite[1][1] * verts[k].y +
matComposite[1][2];
verts[k].x = temp;
}
}
void Trangle(wcPt2D* verts)
{
GLint k;
glBegin(GL_TRIANGLES);
for (k = 0; k < 3; k++)
{
glVertex2f(verts[k].x, verts[k].y);
}
glEnd();
}
void WinReshapFcn(GLint newWidth, GLint newHeight)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(xwcMin, xwcMax, ywcMin, ywcMax);
glClear(GL_COLOR_BUFFER_BIT);
}
void DisplayFcn()
{
GLint nVerts = 3;
wcPt2D verts[3] = { {50,25},{150,25 },{100,100} };
wcPt2D centroidPt;
GLint k, xSum = 0, ySum = 0;
for (size_t k = 0; k < nVerts; k++)
{
xSum += verts[k].x;
ySum += verts[k].y;
}
centroidPt.x = GLfloat(xSum) / GLfloat(nVerts);
centroidPt.y = GLfloat(ySum) / GLfloat(nVerts);
wcPt2D pivPt, fixedPt;
pivPt = centroidPt;
fixedPt = centroidPt;
GLfloat tx = 0, ty = 100;
GLfloat sx = 0.5, sy = 0.5;
GLdouble theta = pi / 2;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 0, 1);
Trangle(verts);
Matrix3x3SetIdentity(matComposite);
Rotate2D(pivPt, theta);
Translate2D(tx, ty);
TransformVerts2D(nVerts, verts);
glColor3f(1, 0, 0);
Trangle(verts);
glFlush();
}
void draw_pixel(int ix, int iy)
{
glBegin(GL_POINTS);
glVertex2i(ix, iy);
glEnd();
}
void myinit()
{
glClearColor(1.0, 0.8, 1.0, 1.0);
glColor3f(0.0, 0.5, 0.5);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 500);
glutInitWindowPosition(150.0, 150.0);
glutCreateWindow("圖像旋轉(zhuǎn)變換");
glutDisplayFunc(DisplayFcn);
glutReshapeFunc(WinReshapFcn);
myinit();
glutMainLoop();
}
運(yùn)行結(jié)果:
?
??2.5.3?對稱變換
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
GLsizei winWidth = 600, winHeight = 600;
GLfloat xwcMin = 0.0, xwcMax = 225.0;
GLfloat ywcMin = 0.0, ywcMax = 225.0;
class wcPt2D
{
public:
GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.14159;
void Init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
}
void Matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
GLint row, col;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matIdent3x3[row][col] = (row == col);
}
}
}
void Matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
GLint row, col;
Matrix3x3 matTemp;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matTemp[row][col] =
m1[row][0] * m2[0][col] +
m1[row][1] * m2[1][col] +
m1[row][2] * m2[2][col];
}
}
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
m2[row][col] = matTemp[row][col];
}
}
}
void Translate2D(GLfloat tx, GLfloat ty)
{
Matrix3x3 matTransl;
Matrix3x3SetIdentity(matTransl);
matTransl[0][2] = tx;
matTransl[1][2] = ty;
Matrix3x3PreMultiply(matTransl, matComposite);
}
void Rotate2D(wcPt2D pivotPt, GLfloat theta)//旋轉(zhuǎn)
{
Matrix3x3 matRot;
Matrix3x3SetIdentity(matRot);
matRot[0][0] = cos(theta);
matRot[0][1] = -sin(theta);
matRot[0][2] = pivotPt.x * (1 - cos(theta)) +
pivotPt.y * sin(theta);
matRot[1][0] = sin(theta);
matRot[1][1] = cos(theta);
matRot[1][2] = pivotPt.y * (1 - cos(theta)) -
pivotPt.x * sin(theta);
Matrix3x3PreMultiply(matRot, matComposite);
}
void TransformVerts2D(GLint nVerts, wcPt2D* verts)//平移
{
GLint k;
GLfloat temp;
for (k = 0; k < nVerts; k++)
{
temp = matComposite[0][0] * verts[k].x +
matComposite[0][1] * verts[k].y +
matComposite[0][2];
verts[k].y = matComposite[1][0] * verts[k].x +
matComposite[1][1] * verts[k].y +
matComposite[1][2];
verts[k].x = temp;
}
}
void Trangle(wcPt2D* verts)
{
GLint k;
glBegin(GL_TRIANGLES);
for (k = 0; k < 3; k++)
{
glVertex2f(verts[k].x, verts[k].y);
}
glEnd();
}
void WinReshapFcn(GLint newWidth, GLint newHeight)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(xwcMin, xwcMax, ywcMin, ywcMax);
glClear(GL_COLOR_BUFFER_BIT);
}
void DisplayFcn()
{
GLint nVerts = 3;
wcPt2D verts[3] = { {50,25},{150,25 },{100,100} };
wcPt2D centroidPt;
GLint k, xSum = 0, ySum = 0;
for (size_t k = 0; k < nVerts; k++)
{
xSum += verts[k].x;
ySum += verts[k].y;
}
centroidPt.x = GLfloat(xSum) / GLfloat(nVerts);
centroidPt.y = GLfloat(ySum) / GLfloat(nVerts);
wcPt2D pivPt, fixedPt;
pivPt = centroidPt;
fixedPt = centroidPt;
GLfloat tx = 0, ty = 100;
GLfloat sx = 0.5, sy = 0.5;
GLdouble theta = pi;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 0, 1);
Trangle(verts);
Matrix3x3SetIdentity(matComposite);
Rotate2D(pivPt, theta);
Translate2D(tx, ty);
TransformVerts2D(nVerts, verts);
glColor3f(1, 0, 0);
Trangle(verts);
glFlush();
}
void draw_pixel(int ix, int iy)
{
glBegin(GL_POINTS);
glVertex2i(ix, iy);
glEnd();
}
void myinit()
{
glClearColor(1.0, 0.8, 1.0, 1.0);
glColor3f(0.0, 0.5, 0.5);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 500);
glutInitWindowPosition(150.0, 150.0);
glutCreateWindow("圖像對稱變換");
glutDisplayFunc(DisplayFcn);
glutReshapeFunc(WinReshapFcn);
myinit();
glutMainLoop();
}
運(yùn)行結(jié)果:
?
??2.5.4?比例變換
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
GLsizei winWidth = 600, winHeight = 600;
GLfloat xwcMin = 0.0, xwcMax = 225.0;
GLfloat ywcMin = 0.0, ywcMax = 225.0;
class wcPt2D
{
public:
GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.14159;
void Init()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
}
void Matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
GLint row, col;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matIdent3x3[row][col] = (row == col);
}
}
}
void Matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
GLint row, col;
Matrix3x3 matTemp;
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
matTemp[row][col] =
m1[row][0] * m2[0][col] +
m1[row][1] * m2[1][col] +
m1[row][2] * m2[2][col];
}
}
for (row = 0; row < 3; row++)
{
for (col = 0; col < 3; col++)
{
m2[row][col] = matTemp[row][col];
}
}
}
void Translate2D(GLfloat tx, GLfloat ty)
{
Matrix3x3 matTransl;
Matrix3x3SetIdentity(matTransl);
matTransl[0][2] = tx;
matTransl[1][2] = ty;
Matrix3x3PreMultiply(matTransl, matComposite);
}
void Scale2D(GLfloat sx, GLfloat sy, wcPt2D fixedPt)//縮放
{
Matrix3x3 matScale;
Matrix3x3SetIdentity(matScale);
matScale[0][0] = sx;
matScale[0][2] = (1 - sx) * fixedPt.x;
matScale[1][1] = sy;
matScale[1][2] = (1 - sy) * fixedPt.y;
Matrix3x3PreMultiply(matScale, matComposite);
}
void TransformVerts2D(GLint nVerts, wcPt2D* verts)//平移
{
GLint k;
GLfloat temp;
for (k = 0; k < nVerts; k++)
{
temp = matComposite[0][0] * verts[k].x +
matComposite[0][1] * verts[k].y +
matComposite[0][2];
verts[k].y = matComposite[1][0] * verts[k].x +
matComposite[1][1] * verts[k].y +
matComposite[1][2];
verts[k].x = temp;
}
}
void Trangle(wcPt2D* verts)
{
GLint k;
glBegin(GL_TRIANGLES);
for (k = 0; k < 3; k++)
{
glVertex2f(verts[k].x, verts[k].y);
}
glEnd();
}
void WinReshapFcn(GLint newWidth, GLint newHeight)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(xwcMin, xwcMax, ywcMin, ywcMax);
glClear(GL_COLOR_BUFFER_BIT);
}
void DisplayFcn()
{
GLint nVerts = 3;
wcPt2D verts[3] = { {50,25},{150,25 },{100,100} };
wcPt2D centroidPt;
GLint k, xSum = 0, ySum = 0;
for (size_t k = 0; k < nVerts; k++)
{
xSum += verts[k].x;
ySum += verts[k].y;
}
centroidPt.x = GLfloat(xSum) / GLfloat(nVerts);
centroidPt.y = GLfloat(ySum) / GLfloat(nVerts);
wcPt2D pivPt, fixedPt;
pivPt = centroidPt;
fixedPt = centroidPt;
GLfloat tx = 0, ty = 100;
GLfloat sx = 0.5, sy = 0.5;
GLdouble theta = pi / 2;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 0, 1);
Trangle(verts);
Matrix3x3SetIdentity(matComposite);
Scale2D(sx, sy, fixedPt);
Translate2D(tx, ty);
TransformVerts2D(nVerts, verts);
glColor3f(1, 0, 0);
Trangle(verts);
glFlush();
}
void draw_pixel(int ix, int iy)
{
glBegin(GL_POINTS);
glVertex2i(ix, iy);
glEnd();
}
void myinit()
{
glClearColor(1.0, 0.8, 1.0, 1.0);
glColor3f(0.0, 0.5, 0.5);
glPointSize(1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 500);
glutInitWindowPosition(150.0, 150.0);
glutCreateWindow("圖像比例變換");
glutDisplayFunc(DisplayFcn);
glutReshapeFunc(WinReshapFcn);
myinit();
glutMainLoop();
}
運(yùn)行結(jié)果:
?
??2.4 研究體會
-
實(shí)驗(yàn)內(nèi)容完成: 通過本次實(shí)驗(yàn),我成功地完成了圖像平移、旋轉(zhuǎn)、對稱和比例縮放等變換操作。為了提高圖像顯示效果的清晰度,我在旋轉(zhuǎn)、對稱和縮放變換中添加了平移操作,以避免變換后的圖像與原圖重疊。這使我對圖像變換操作有了深入的理解和實(shí)際操作經(jīng)驗(yàn)。
-
自學(xué)與應(yīng)用場景差距: 通過構(gòu)造幾何圖像并進(jìn)行變換操作,我意識到在實(shí)際應(yīng)用場景中,通常是對給定的圖像進(jìn)行變換操作,而不是自己構(gòu)造圖像。雖然我在Python中對圖像操作較為熟悉,但在C++中感覺到需要從頭編寫并控制每個(gè)功能。盡管這樣的學(xué)習(xí)方式較為理想,但在實(shí)際應(yīng)用中可能需要更多的庫函數(shù)支持。
-
學(xué)習(xí)過程中的挑戰(zhàn)和成就感: 實(shí)驗(yàn)中我花費(fèi)了較多時(shí)間在圖像生成的控制上,包括輸出面板底色、圖像初始位置和輸出框大小等方面。由于之前主要在Dev-C++平臺編程,初次使用Visual Studio 2022平臺感到不太順手,但通過自學(xué)和網(wǎng)上查找資料逐漸適應(yīng)。最終看到運(yùn)行結(jié)果時(shí),感受到了付出的回報(bào),同時(shí)也認(rèn)識到在學(xué)習(xí)過程中需要保持耐心和專注。這次實(shí)驗(yàn)使我更加深入地了解了圖形學(xué),也激發(fā)了我對編程的熱情和學(xué)習(xí)的動力。
??總結(jié)
圖形學(xué)領(lǐng)域宛如一片廣闊而未被完全探索的創(chuàng)意海洋,邀請你勇敢踏足數(shù)字藝術(shù)和計(jì)算機(jī)圖形學(xué)的神秘領(lǐng)域。這是一場富有創(chuàng)意和技術(shù)挑戰(zhàn)的學(xué)習(xí)之旅,從基礎(chǔ)概念到算法實(shí)現(xiàn),逐步揭示更深層次的圖形分析、渲染技術(shù)和智能圖形識別的奧秘??释魬?zhàn)圖形學(xué)的學(xué)習(xí)路徑和掌握計(jì)算機(jī)藝術(shù)的技能?不妨點(diǎn)擊下方鏈接,一同探討更多數(shù)字創(chuàng)意的奇跡吧。我們推出了引領(lǐng)趨勢的?? 計(jì)算機(jī)圖形學(xué)專欄:《藝術(shù)之光 | 數(shù)字創(chuàng)新解鎖》,旨在深度探索圖形學(xué)技術(shù)的實(shí)際應(yīng)用和創(chuàng)新。????
文章來源:http://www.zghlxwxcb.cn/news/detail-804872.html
?
到了這里,關(guān)于【圖形學(xué)】探秘圖形學(xué)奧秘:圖形變換的解密與實(shí)戰(zhàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!