EMAN::TestTomoImage Class Reference

Make an image useful for tomographic reconstruction testing this is a 3D phantom image based on the 2D phantom described in Delaney and Bresler, "Globally convergent edge-preserving regularized reconstruction: An application to limited-angle tomography". More...

#include <processor.h>

Inheritance diagram for EMAN::TestTomoImage:

Inheritance graph
[legend]
Collaboration diagram for EMAN::TestTomoImage:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 Make a useful tomographic phantom image.
virtual string get_name () const
 Get the processor's name.
virtual string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "testimage.tomo.objects"

Private Member Functions

void insert_solid_ellipse (EMData *image, const Region &region, const float &value, const Transform &t3d=Transform())
void insert_hollow_ellipse (EMData *image, const Region &region, const float &value, const int &radius, const Transform &t3d=Transform())
void insert_rectangle (EMData *image, const Region &region, const float &value, const Transform &t3d=Transform())

Detailed Description

Make an image useful for tomographic reconstruction testing this is a 3D phantom image based on the 2D phantom described in Delaney and Bresler, "Globally convergent edge-preserving regularized reconstruction: An application to limited-angle tomography".

IEEE Transactions on Image Processing, 7(2), Feb 1998, 204-221.

Author:
David Woolford
Date:
November 2007

Definition at line 6050 of file processor.h.


Member Function Documentation

virtual string EMAN::TestTomoImage::get_desc (  )  const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 6063 of file processor.h.

06064                         {
06065                                 return "Make an image consisting various objects, useful for tomographic testing";
06066                         }

virtual string EMAN::TestTomoImage::get_name (  )  const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 6058 of file processor.h.

References NAME.

06059                         {
06060                                 return NAME;
06061                         }

void EMAN::TestTomoImage::insert_hollow_ellipse ( EMData image,
const Region region,
const float &  value,
const int &  radius,
const Transform t3d = Transform() 
) [private]

void TestTomoImage::insert_rectangle ( EMData image,
const Region region,
const float &  value,
const Transform t3d = Transform() 
) [private]

Definition at line 8929 of file processor.cpp.

References EMAN::Transform::is_identity(), EMAN::Region::origin, EMAN::EMData::set_value_at(), EMAN::Region::size, v, and x.

Referenced by process_inplace().

08930 {
08931         int startx = (int)region.origin[0] - (int)region.size[0]/2;
08932         int starty = (int)region.origin[1] - (int)region.size[1]/2;
08933         int startz = (int)region.origin[2] - (int)region.size[2]/2;
08934 
08935         int endx  = (int)region.origin[0] + (int)region.size[0]/2;
08936         int endy  = (int)region.origin[1] + (int)region.size[1]/2;
08937         int endz  = (int)region.origin[2] + (int)region.size[2]/2;
08938 
08939         if ( ! t3d.is_identity() ) {
08940                 float xt, yt, zt;
08941                 for ( float z = (float)startz; z < (float)endz; z += 0.25f ) {
08942                         for ( float y = (float)starty; y < (float)endy; y += 0.25f ) {
08943                                 for ( float x = (float)startx; x < (float)endx; x += 0.25f ) {
08944                                         xt = (float) x - region.origin[0];
08945                                         yt = (float) y - region.origin[1];
08946                                         zt = (float) z - region.origin[2];
08947                                         Vec3f v((float)xt,(float)yt,(float)zt);
08948                                         v = t3d*v;
08949                                         image->set_value_at((int)(v[0]+region.origin[0]),(int)(v[1]+region.origin[1]),(int)(v[2]+region.origin[2]), value);
08950                                 }
08951                         }
08952                 }
08953         } else {
08954                 for ( int z = startz; z < endz; ++z ) {
08955                         for ( int y = starty; y < endy; ++y ) {
08956                                 for ( int x = startx; x < endx; ++x ) {
08957                                         image->set_value_at(x,y,z, value);
08958                                 }
08959                         }
08960                 }
08961         }
08962 }

void EMAN::TestTomoImage::insert_solid_ellipse ( EMData image,
const Region region,
const float &  value,
const Transform t3d = Transform() 
) [private]

static Processor* EMAN::TestTomoImage::NEW (  )  [inline, static]

Definition at line 6068 of file processor.h.

06069                         {
06070                                 return new TestTomoImage();
06071                         }

void TestTomoImage::process_inplace ( EMData image  )  [virtual]

Make a useful tomographic phantom image.

Parameters:
image the image to operate upon

Implements EMAN::Processor.

Definition at line 8964 of file processor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), insert_rectangle(), EMAN::EMData::process_inplace(), and t.

08965 {
08966         //float nx = 240;
08967         //float ny = 240;
08968         //float nz = 60;
08969 
08970         //image->set_size((int)nx,(int)ny,(int)nz);
08971         float nx = (float) image->get_xsize();
08972         float ny = (float) image->get_ysize();
08973         float nz = (float) image->get_zsize();
08974 
08975         // This increment is used to simplified positioning
08976         // It's an incremental factor that matches the grid size of the paper
08977         // that I drew this design on before implementing it in code
08978         float inc = 1.0f/22.0f;
08979         float xinc = inc;
08980         float yinc = inc;
08981         float zinc = inc;
08982 
08983         Dict d;
08984         d["a"] = (float) .4*nx+3;
08985         d["b"] = (float) .4*ny+3;
08986         d["c"] = (float) .4*nz+3;
08987         d["fill"] = 0.2;
08988         image->process_inplace("testimage.ellipsoid",d);
08989 
08990         d["a"] = (float) .4*nx;
08991         d["b"] = (float) .4*ny;
08992         d["c"] = (float) .4*nz;
08993         d["fill"] = 0.1;
08994         image->process_inplace("testimage.ellipsoid",d);
08995 
08996         // Center x, center z, bottom y ellipsoids that grow progessively smaller
08997         {
08998                 Transform t;
08999                 t.set_trans(0.,ny*4.0f*yinc-ny/2,0);
09000                 Dict d;
09001                 d["transform"] = &t;
09002                 d["a"] = (float) 2.*xinc*nx;
09003                 d["b"] = (float)0.5*yinc*ny;
09004                 d["c"] = (float) 1.*zinc*nz;
09005                 d["fill"] = 0.3;
09006                 image->process_inplace("testimage.ellipsoid",d);
09007         }
09008 
09009         {
09010                 Transform t;
09011                 t.set_trans(0.,ny*5.5f*yinc-ny/2,0);
09012                 Dict d;
09013                 d["transform"] = &t;
09014                 d["a"] = (float) 1.5*xinc*nx;
09015                 d["b"] = (float)0.5*yinc*ny;
09016                 d["c"] = (float) 1.*zinc*nz;
09017                 d["fill"] = 0.0;
09018                 image->process_inplace("testimage.ellipsoid",d);
09019         }
09020         {
09021                 Transform t;
09022                 t.set_trans(0.,ny*7*yinc-ny/2,0);
09023                 Dict d;
09024                 d["transform"] = &t;
09025                 d["a"] = (float) 1.*xinc*nx;
09026                 d["b"] = (float)0.5*yinc*ny;
09027                 d["c"] = (float) 1.*zinc*nz;
09028                 d["fill"] = 0.3;
09029                 image->process_inplace("testimage.ellipsoid",d);
09030         }
09031 
09032 
09033         {
09034                 Transform t;
09035                 t.set_trans(0.,ny*8.5f*yinc-ny/2,0);
09036                 Dict d;
09037                 d["transform"] = &t;
09038                 d["a"] = (float) .75*xinc*nx;
09039                 d["b"] = (float)0.5*yinc*ny;
09040                 d["c"] = (float) 1.*zinc*nz;
09041                 d["fill"] = 0.0;
09042                 image->process_inplace("testimage.ellipsoid",d);
09043         }
09044 
09045         // Center x, center z, bottom y ellipsoids that grow progessively smaller
09046         {
09047                 Transform t;
09048                 t.set_trans(0.,ny*18*yinc-ny/2,0);
09049                 Dict d;
09050                 d["transform"] = &t;
09051                 d["a"] = (float) 2*xinc*nx;
09052                 d["b"] = (float)0.5*yinc*ny;
09053                 d["c"] = (float) 1.*zinc*nz;
09054                 d["fill"] = 0.3;
09055                 image->process_inplace("testimage.ellipsoid",d);
09056         }
09057 
09058         {
09059                 Transform t;
09060                 t.set_trans(0.,ny*16.5f*yinc-ny/2,0);
09061                 Dict d;
09062                 d["transform"] = &t;
09063                 d["a"] = (float) 1.5*xinc*nx;
09064                 d["b"] = (float)0.5*yinc*ny;
09065                 d["c"] = (float) 1.*zinc*nz;
09066                 d["fill"] = 0.3;
09067                 image->process_inplace("testimage.ellipsoid",d);
09068         }
09069 
09070         {
09071                 Transform t;
09072                 t.set_trans(0.,ny*15*yinc-ny/2,0);
09073                 Dict d;
09074                 d["transform"] = &t;
09075                 d["a"] = (float) 1*xinc*nx;
09076                 d["b"] = (float)0.5*yinc*ny;
09077                 d["c"] = (float) 1.*zinc*nz;
09078                 d["fill"] = 0.3f;
09079                 image->process_inplace("testimage.ellipsoid",d);
09080         }
09081 
09082         {
09083                 Transform t;
09084                 t.set_trans(0.,ny*13.5f*yinc-ny/2,0);
09085                 Dict d;
09086                 d["transform"] = &t;
09087                 d["a"] = (float).75*xinc*nx;
09088                 d["b"] = (float)0.5*yinc*ny;
09089                 d["c"] = (float) 1.*zinc*nz;
09090                 d["fill"] = 0.3;
09091                 image->process_inplace("testimage.ellipsoid",d);
09092         }
09093 
09094         // Left ellipsoids from the bottom up
09095         {
09096 
09097                 Transform t;
09098                 t.set_trans(nx*6*xinc-nx/2,ny*5*yinc-ny/2,0);
09099                 Dict d;
09100                 d["transform"] = &t;
09101                 d["a"] = (float)1*xinc*nx;
09102                 d["b"] = (float).75*yinc*ny;
09103                 d["c"] = (float) .75*zinc*nz;
09104                 d["fill"] = 0.25;
09105                 image->process_inplace("testimage.ellipsoid",d);
09106         }
09107 
09108         {
09109                 Transform t;
09110                 t.set_trans(nx*6*xinc-nx/2,ny*7*yinc-ny/2,0);
09111                 Dict d;
09112                 d["transform"] = &t;
09113                 d["a"] = (float)1.5*xinc*nx;
09114                 d["b"] = (float).75*yinc*ny;
09115                 d["c"] = (float) .75*zinc*nz;
09116                 d["fill"] = 0.25;
09117                 image->process_inplace("testimage.ellipsoid",d);
09118         }
09119 
09120         {
09121                 Transform t;
09122                 t.set_trans(nx*6*xinc-nx/2,ny*9*yinc-ny/2,0);
09123                 Dict d;
09124                 d["transform"] = &t;
09125                 d["a"] = (float)2*xinc*nx;
09126                 d["b"] = (float).75*yinc*ny;
09127                 d["c"] = (float) .75*zinc*nz;
09128                 d["fill"] = 0.25;
09129                 image->process_inplace("testimage.ellipsoid",d);
09130         }
09131 
09132         {
09133                 Transform t;
09134                 t.set_trans(nx*6*xinc-nx/2,ny*11*yinc-ny/2,0);
09135                 Dict d;
09136                 d["transform"] = &t;
09137                 d["a"] = (float)2.5*xinc*nx;
09138                 d["b"] = (float).75*yinc*ny;
09139                 d["c"] = (float) 1*zinc*nz;
09140                 d["fill"] = 0.25;
09141                 image->process_inplace("testimage.ellipsoid",d);
09142         }
09143 
09144         {
09145                 Transform t;
09146                 t.set_trans(nx*6*xinc-nx/2,ny*13*yinc-ny/2,0);
09147                 Dict d;
09148                 d["transform"] = &t;
09149                 d["a"] = (float) 3*xinc*nx;
09150                 d["b"] = (float).75*yinc*ny;
09151                 d["c"] = (float) 1*zinc*nz;
09152                 d["fill"] = 0.25;
09153                 image->process_inplace("testimage.ellipsoid",d);
09154         }
09155 
09156         // Right rectangle from the top down
09157         {
09158                 Region region(nx*15.*inc,ny*17.*inc,nz/2.,1.*inc*nx,1.5*inc*ny,1.5*inc*nz);
09159                 insert_rectangle(image, region, 0.25);
09160         }
09161         {
09162                 Region region(nx*15.*inc,ny*15.*inc,nz/2.,1.5*inc*nx,1.5*inc*ny,1.5*inc*nz);
09163                 insert_rectangle(image, region, 0.25);
09164         }
09165         {
09166                 Region region(nx*15.*inc,ny*13.*inc,nz/2.,2.*inc*nx,1.5*inc*ny,1.5*inc*nz);
09167                 insert_rectangle(image, region, 0.25);
09168         }
09169         {
09170                 Region region(nx*15.*inc,ny*11.*inc,nz/2.,2.5*inc*nx,1.5*inc*ny,1.5*inc*nz);
09171                 insert_rectangle(image, region, 0.25);
09172         }
09173         {
09174                 Region region(nx*15.*inc,ny*9.*inc,nz/2.,3.*inc*nx,1.5*inc*ny,1.5*inc*nz);
09175                 insert_rectangle(image, region, 0.25);
09176         }
09177 
09178         // Center rotated rectangle
09179         {
09180                 Region region(nx/2.,ny/2.,nz/2.,2.*inc*nx,2.5*inc*ny,1.*inc*nz);
09181                 Transform t3d(Dict("type","eman","az",(float)-25.0));
09182                 insert_rectangle(image, region, 0.4f, t3d);
09183         }
09184 
09185         // Rotated ellipsoids
09186         {
09187                 Transform t;
09188                 t.set_trans(nx*6.8f*xinc-nx/2,ny*16*yinc-ny/2,0);
09189                 Dict rot;
09190                 rot["type"] = "eman";
09191                 rot["az"] = 43.0f;
09192                 t.set_rotation(rot);
09193                 Dict d;
09194                 d["transform"] = &t;
09195                 d["a"] = (float) 1.5*xinc*nx;
09196                 d["b"] = (float) .5*yinc*ny;
09197                 d["c"] = (float) .5*zinc*nz;
09198                 d["fill"] = 0.2;
09199                 image->process_inplace("testimage.ellipsoid",d);
09200         }
09201         {
09202                 Transform t;
09203                 t.set_trans(nx*7.2f*xinc-nx/2,ny*16*yinc-ny/2,0);
09204                 Dict rot;
09205                 rot["type"] = "eman";
09206                 rot["az"] = 135.0f;
09207                 t.set_rotation(rot);
09208                 Dict d;
09209                 d["transform"] = &t;
09210                 d["a"] = (float) 1.5*xinc*nx;
09211                 d["b"] = (float) .5*yinc*ny;
09212                 d["c"] = (float) .5*zinc*nz;
09213                 d["fill"] = 0.3;
09214                 image->process_inplace("testimage.ellipsoid",d);
09215         }
09216 
09217         // Dense small ellipsoids
09218         {
09219                 Transform t;
09220                 t.set_trans(nx*3.5f*xinc-nx/2,ny*8*yinc-ny/2,0);
09221                 Dict d;
09222                 d["transform"] = &t;
09223                 d["a"] = (float) .5*xinc*nx;
09224                 d["b"] = (float) .5*yinc*ny;
09225                 d["c"] = (float) .5*zinc*nz;
09226                 d["fill"] = 2.05;
09227                 image->process_inplace("testimage.ellipsoid",d);
09228 
09229                 t.set_trans(nx*8*xinc-nx/2,ny*18*yinc-ny/2,0);
09230                 image->process_inplace("testimage.ellipsoid",d);
09231 
09232                 t.set_trans(nx*14*xinc-nx/2,ny*18.2f*yinc-ny/2,0);
09233                 image->process_inplace("testimage.ellipsoid",d);
09234 
09235                 t.set_trans(nx*18*xinc-nx/2,ny*14*yinc-ny/2,0);
09236                 image->process_inplace("testimage.ellipsoid",d);
09237 
09238                 t.set_trans(nx*17*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
09239                 image->process_inplace("testimage.ellipsoid",d);
09240         }
09241 
09242 
09243         // Dense small rectangles
09244         {
09245                 Region region(nx*18.*inc,ny*11.5*inc,nz/2.,1.*inc*nx,1.*inc*ny,1.*inc*nz);
09246                 Transform t3d(Dict("type","eman","az",(float)45.0));
09247                 insert_rectangle(image, region, 1.45f, t3d);
09248         }
09249         {
09250                 Region region(nx*3.*inc,ny*10.5*inc,nz/2.,1.*inc*nx,1.*inc*ny,1.*inc*nz);
09251                 Transform t3d(Dict("type","eman","az",(float)45.0));
09252                 insert_rectangle(image, region, 1.45f, t3d);
09253         }
09254 
09255         // Insert small cluster of spheres
09256         {
09257                 Transform t;
09258                 t.set_trans(nx*14*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
09259                 Dict d;
09260                 d["transform"] = &t;
09261                 d["a"] = (float) .5*xinc*nx;
09262                 d["b"] = (float) .5*yinc*ny;
09263                 d["c"] = (float) .5*zinc*nz;
09264                 d["fill"] = .35;
09265                 image->process_inplace("testimage.ellipsoid",d);
09266         }
09267         {
09268                 Transform t;
09269                 t.set_trans(nx*15*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
09270                 Dict d;
09271                 d["transform"] = &t;
09272                 d["a"] = (float) .25*xinc*nx;
09273                 d["b"] = (float) .25*yinc*ny;
09274                 d["c"] = (float) .25*zinc*nz;
09275                 d["fill"] = .35;
09276                 image->process_inplace("testimage.ellipsoid",d);
09277 
09278                 t.set_trans(nx*13.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
09279                 image->process_inplace("testimage.ellipsoid",d);
09280 
09281                 t.set_trans(nx*14.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
09282                 image->process_inplace("testimage.ellipsoid",d);
09283 
09284                 t.set_trans(nx*15.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
09285                 image->process_inplace("testimage.ellipsoid",d);
09286 
09287                 t.set_trans(nx*14*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
09288                 image->process_inplace("testimage.ellipsoid",d);
09289 
09290                 t.set_trans(nx*14*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
09291                 image->process_inplace("testimage.ellipsoid",d);
09292 
09293                 t.set_trans(nx*15*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
09294                 image->process_inplace("testimage.ellipsoid",d);
09295 
09296                 t.set_trans(nx*16*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
09297                 image->process_inplace("testimage.ellipsoid",d);
09298 
09299                 t.set_trans(nx*14.5f*xinc-nx/2,ny*4.5f*yinc-ny/2,0);
09300                 image->process_inplace("testimage.ellipsoid",d);
09301 
09302                 t.set_trans(nx*15.5f*xinc-nx/2,ny*4.5f*yinc-ny/2,0);
09303                 image->process_inplace("testimage.ellipsoid",d);
09304         }
09305         // Insert feducials around the outside of the "cell"
09306 //      for ( float i = 0.; i < 3.; i += 1. ) {
09307 //              for ( float j = 0.; j < 3.; j += 1. ) {
09308 //                      Region region(nx*2.+i*inc,ny*2.+j*inc,nz/2.,0.05*inc*nx,0.05*inc*ny,0.05*inc*nz);
09309 //                      insert_solid_ellipse(image, region, 2.0);
09310 //              }
09311 //      }
09312 
09313 }


Member Data Documentation

const string TestTomoImage::NAME = "testimage.tomo.objects" [static]

Definition at line 6073 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:50 2012 for EMAN2 by  doxygen 1.4.7