资源简介
c++程序编写的sart算法重建程序,是我的毕业设计,其中包括直线的建立,投影系数的求法和sart公式的实现。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
//#include
#define PICWIDTH 256
#define PICWIDTH1 256
//#define ANGLESCOUNT 180
//#define PI 3.1415926535897932
#define PIperp 0.01745329252
#define ANGLESCOUNT 180
//double NewPicBits[PICWIDTH * PICWIDTH] = {0};
bool CrossPoint(double line1[3] double line2[3] double crosspoint[2]);
void ParaRadialLine(int receiverWidth int thet int n double line[3]);
double TwoOneDMatrix(double M1[] double M2[]);
double sum(double N[]);
//bool GetR2(int num double pR[PICWIDTH * PICWIDTH]);
bool GetR2(int num double pr[2*PICWIDTH] int pn[2*PICWIDTH]);
double TwoOneD(double M1[] double M2[]);
double sum1(double N[]);
double min(double adouble b);
bool CrossPoint(double line1[3] double line2[3] double crosspoint[2])
{
if(line1[2] != 0 && line2[2]!= 0) //两线均不垂直
{
//if(line1[0] == line2[0] && line1[1] == line2[1])
if(line1[0] == line2[0])
{
return false;
}
crosspoint[0] = (line1[2] * line2[1] - line2[2] * line1[1])
/(line2[2] * line1[0] - line1[2] * line2[0]);
crosspoint[1] = (line1[1] * line2[0] - line2[1] * line1[0])
/(line2[0] * line1[2] - line1[0] * line2[2]);
return true;
}
else if(line1[2] == 0 && line2[2] != 0)
{
crosspoint[0] = - (line1[1]/line1[0]);
crosspoint[1] = (line2[0] * crosspoint[0] + line2[1])/line2[2];
return true;
}
else if(line1[2] != 0 && line2[2] == 0)
{
crosspoint[0] = - (line2[1]/line2[0]);
crosspoint[1] = (line1[0] * crosspoint[0] + line1[1])/line1[2];
return true;
}
return false;
}
void ParaRadialLine(int receiverWidth int thet int n double line[3]) //n counts from 1
{
double delta;//产生平行线
delta = (double) receiverWidth/(PICWIDTH1);
double tempxtempy;
int flag; //判定在左边还是右边 1为左边,-1为右边
flag = (int) ((double)(PICWIDTH*0.5 -0.5 -n)/(fabs((double) (PICWIDTH*0.5 -0.5 -n))));
if(thet > 0 && thet < 90 )
{
tempy = - flag * sqrt( pow((fabs(128-n) * delta) 2)
/ (1+ pow((1/tan(thet*PIperp)) 2)));
tempx = tempy / (tan(thet*PIperp));
line[0] = - 1/(tan(thet*PIperp));
// line[1] = tempy - line[0] * tempx;
line[1] = -flag*(fabs(128-n)* delta)/sin(thet*PIperp);
line[2] = 1;
}
else if(thet > 90 && thet < 180)
{
tempy = - flag * sqrt( pow((fabs(128-n) * delta) 2)
/ (1+ pow((1/tan(thet*PIperp)) 2)));
tempx = tempy / (tan(thet*PIperp));
line[0] = - 1/(tan(thet*PIperp));
// line[1] = tempy - line[0] * tempx;
line[1] = flag*(fabs(128-n)* delta)/sin(thet*PIperp);
line[2] = 1;
}
else if(thet == 90)
{
tempy = - flag * sqrt(pow(( fabs(128-n) * delta) 2));
tempx = 0;
line[0] = 0;
line[1] = tempy;
line[2] = 1;
}
else
{
tempx = - flag * sqrt(pow(( fabs(128-n) * delta) 2));
tempy = 0;
line[0] = 1;
line[1] = -tempx;
line[2] = 0;
}
}
bool GetR2(i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 368640 2011-04-13 20:55 sss 1\a1.bin
文件 524288 2011-04-18 20:28 sss 1\b1.bin
文件 66614 2011-04-15 13:39 sss 1\B1.BMP
文件 2048 2011-04-18 20:28 sss 1\d1.txt
文件 229429 2011-04-18 20:28 sss 1\Debug\sss.exe
文件 250352 2011-04-18 20:28 sss 1\Debug\sss.ilk
文件 21030 2011-04-18 20:28 sss 1\Debug\sss.obj
文件 43520 2011-04-08 20:19 sss 1\Debug\sss.opt
文件 239376 2011-04-12 16:47 sss 1\Debug\sss.pch
文件 508928 2011-04-18 20:28 sss 1\Debug\sss.pdb
文件 41984 2011-04-18 20:28 sss 1\Debug\vc60.idb
文件 53248 2011-04-18 20:28 sss 1\Debug\vc60.pdb
文件 66614 2011-04-18 20:49 sss 1\SART1.BMP
文件 18216 2011-04-18 21:35 sss 1\sss.cpp
文件 3365 2011-03-30 14:53 sss 1\sss.dsp
文件 514 2011-03-30 14:54 sss 1\sss.dsw
文件 50176 2011-04-20 16:11 sss 1\sss.ncb
文件 54784 2011-04-20 16:11 sss 1\sss.opt
文件 1272 2011-04-18 20:28 sss 1\sss.plg
目录 0 2011-04-18 20:28 sss 1\Debug
目录 0 2011-04-20 16:11 sss 1
----------- --------- ---------- ----- ----
2544398 21
- 上一篇:MFC课设代码(扫雷游戏
- 下一篇:c语言编程中常见的陷阱和漏洞
评论
共有 条评论