00001
00002 #include "btom_slice_simulator.h"
00003
00004
00005
00006 #include <vcl_cmath.h>
00007 #include <vcl_vector.h>
00008 #include <btom/btom_gauss_cylinder.h>
00009 #include <btom/btom_gauss_cylinder_sptr.h>
00010
00011
00012
00013
00014
00015
00016
00017 btom_slice_simulator::btom_slice_simulator(btom_slice_simulator_params& ssp)
00018 : btom_slice_simulator_params(ssp)
00019 {
00020 }
00021
00022 btom_slice_simulator::~btom_slice_simulator()
00023 {
00024 }
00025
00026 void btom_slice_simulator::gaussian_sinogram(vil1_memory_image_of<float> & sinogram,
00027 vil1_memory_image_of<float> & reconst)
00028 {
00029 int xmax = 512, ymax = 512, off = 64;
00030 float xt = xmax*0.5f, yt = ymax*0.5f;
00031 int theta_max = 360;
00032 int tmax = (int)vcl_sqrt(double((xmax)*(xmax)+(ymax)*(ymax)));
00033 int tt = (tmax-1)/2;
00034 sinogram.resize(theta_max,tmax);
00035 reconst.resize(xmax, ymax);
00036 reconst.fill(0.0);
00037
00038 vcl_vector<btom_gauss_cylinder_sptr> cyls;
00039 double linear_cyl = vcl_sqrt(double(ncyl_));
00040 int delta_x = (int)((xmax-2*off)/linear_cyl),
00041 delta_y = (int)((ymax-2*off)/linear_cyl);
00042 float delta_sigma = (max_xy_sigma_-min_xy_sigma_)/ncyl_;
00043 float sigma = min_xy_sigma_;
00044 for (int y = off; y<ymax; y+=delta_y)
00045 for (int x=off; x<xmax; x+= delta_x, sigma+=delta_sigma)
00046 cyls.push_back(new btom_gauss_cylinder(sigma, 5.0, 10.0, 1.0, x-xt, y-yt));
00047
00048 for (int t = -tt; t<tt; t++)
00049 for (int th = 0; th<theta_max; th++)
00050 {
00051 float total_density = 0;
00052 for (vcl_vector<btom_gauss_cylinder_sptr>::iterator cit = cyls.begin();
00053 cit != cyls.end(); cit++)
00054 total_density += (*cit)->radon_transform(float(th),float(t));
00055 sinogram(th,t+tt) = total_density;
00056 }
00057
00058 for (int y = -(int)yt; y<yt; y++)
00059 for (int x=-(int)xt; x<xt; x++)
00060 {
00061 float intensity = 0.0;
00062 for (vcl_vector<btom_gauss_cylinder_sptr>::iterator cit = cyls.begin();
00063 cit != cyls.end(); cit++)
00064 intensity += (*cit)->cylinder_intensity(float(x),float(y));
00065
00066 reconst(int(x+xt),int(y+yt)) = intensity;
00067 }
00068 }