EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
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 6463 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 6476 of file processor.h.

                        {
                                return "Make an image consisting various objects, useful for tomographic testing";
                        }
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 6471 of file processor.h.

References NAME.

                        {
                                return NAME;
                        }
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 9641 of file processor.cpp.

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

{
        int startx = (int)region.origin[0] - (int)region.size[0]/2;
        int starty = (int)region.origin[1] - (int)region.size[1]/2;
        int startz = (int)region.origin[2] - (int)region.size[2]/2;

        int endx  = (int)region.origin[0] + (int)region.size[0]/2;
        int endy  = (int)region.origin[1] + (int)region.size[1]/2;
        int endz  = (int)region.origin[2] + (int)region.size[2]/2;

        if ( ! t3d.is_identity() ) {
                float xt, yt, zt;
                for ( float z = (float)startz; z < (float)endz; z += 0.25f ) {
                        for ( float y = (float)starty; y < (float)endy; y += 0.25f ) {
                                for ( float x = (float)startx; x < (float)endx; x += 0.25f ) {
                                        xt = (float) x - region.origin[0];
                                        yt = (float) y - region.origin[1];
                                        zt = (float) z - region.origin[2];
                                        Vec3f v((float)xt,(float)yt,(float)zt);
                                        v = t3d*v;
                                        image->set_value_at((int)(v[0]+region.origin[0]),(int)(v[1]+region.origin[1]),(int)(v[2]+region.origin[2]), value);
                                }
                        }
                }
        } else {
                for ( int z = startz; z < endz; ++z ) {
                        for ( int y = starty; y < endy; ++y ) {
                                for ( int x = startx; x < endx; ++x ) {
                                        image->set_value_at(x,y,z, value);
                                }
                        }
                }
        }
}
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 6481 of file processor.h.

                        {
                                return new TestTomoImage();
                        }
void TestTomoImage::process_inplace ( EMData image) [virtual]

Make a useful tomographic phantom image.

Parameters:
imagethe image to operate upon

Implements EMAN::Processor.

Definition at line 9676 of file processor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::process_inplace(), EMAN::Transform::set_rotation(), EMAN::Transform::set_trans(), and t.

{
        //float nx = 240;
        //float ny = 240;
        //float nz = 60;

        //image->set_size((int)nx,(int)ny,(int)nz);
        float nx = (float) image->get_xsize();
        float ny = (float) image->get_ysize();
        float nz = (float) image->get_zsize();

        // This increment is used to simplified positioning
        // It's an incremental factor that matches the grid size of the paper
        // that I drew this design on before implementing it in code
        float inc = 1.0f/22.0f;
        float xinc = inc;
        float yinc = inc;
        float zinc = inc;

        Dict d;
        d["a"] = (float) .4*nx+3;
        d["b"] = (float) .4*ny+3;
        d["c"] = (float) .4*nz+3;
        d["fill"] = 0.2;
        image->process_inplace("testimage.ellipsoid",d);

        d["a"] = (float) .4*nx;
        d["b"] = (float) .4*ny;
        d["c"] = (float) .4*nz;
        d["fill"] = 0.1;
        image->process_inplace("testimage.ellipsoid",d);

        // Center x, center z, bottom y ellipsoids that grow progessively smaller
        {
                Transform t;
                t.set_trans(0.,ny*4.0f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 2.*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(0.,ny*5.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1.5*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.0;
                image->process_inplace("testimage.ellipsoid",d);
        }
        {
                Transform t;
                t.set_trans(0.,ny*7*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1.*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }


        {
                Transform t;
                t.set_trans(0.,ny*8.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) .75*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.0;
                image->process_inplace("testimage.ellipsoid",d);
        }

        // Center x, center z, bottom y ellipsoids that grow progessively smaller
        {
                Transform t;
                t.set_trans(0.,ny*18*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 2*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(0.,ny*16.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1.5*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(0.,ny*15*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3f;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(0.,ny*13.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float).75*xinc*nx;
                d["b"] = (float)0.5*yinc*ny;
                d["c"] = (float) 1.*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }

        // Left ellipsoids from the bottom up
        {

                Transform t;
                t.set_trans(nx*6*xinc-nx/2,ny*5*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float)1*xinc*nx;
                d["b"] = (float).75*yinc*ny;
                d["c"] = (float) .75*zinc*nz;
                d["fill"] = 0.25;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(nx*6*xinc-nx/2,ny*7*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float)1.5*xinc*nx;
                d["b"] = (float).75*yinc*ny;
                d["c"] = (float) .75*zinc*nz;
                d["fill"] = 0.25;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(nx*6*xinc-nx/2,ny*9*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float)2*xinc*nx;
                d["b"] = (float).75*yinc*ny;
                d["c"] = (float) .75*zinc*nz;
                d["fill"] = 0.25;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(nx*6*xinc-nx/2,ny*11*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float)2.5*xinc*nx;
                d["b"] = (float).75*yinc*ny;
                d["c"] = (float) 1*zinc*nz;
                d["fill"] = 0.25;
                image->process_inplace("testimage.ellipsoid",d);
        }

        {
                Transform t;
                t.set_trans(nx*6*xinc-nx/2,ny*13*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 3*xinc*nx;
                d["b"] = (float).75*yinc*ny;
                d["c"] = (float) 1*zinc*nz;
                d["fill"] = 0.25;
                image->process_inplace("testimage.ellipsoid",d);
        }

        // Right rectangle from the top down
        {
                Region region(nx*15.*inc,ny*17.*inc,nz/2.,1.*inc*nx,1.5*inc*ny,1.5*inc*nz);
                insert_rectangle(image, region, 0.25);
        }
        {
                Region region(nx*15.*inc,ny*15.*inc,nz/2.,1.5*inc*nx,1.5*inc*ny,1.5*inc*nz);
                insert_rectangle(image, region, 0.25);
        }
        {
                Region region(nx*15.*inc,ny*13.*inc,nz/2.,2.*inc*nx,1.5*inc*ny,1.5*inc*nz);
                insert_rectangle(image, region, 0.25);
        }
        {
                Region region(nx*15.*inc,ny*11.*inc,nz/2.,2.5*inc*nx,1.5*inc*ny,1.5*inc*nz);
                insert_rectangle(image, region, 0.25);
        }
        {
                Region region(nx*15.*inc,ny*9.*inc,nz/2.,3.*inc*nx,1.5*inc*ny,1.5*inc*nz);
                insert_rectangle(image, region, 0.25);
        }

        // Center rotated rectangle
        {
                Region region(nx/2.,ny/2.,nz/2.,2.*inc*nx,2.5*inc*ny,1.*inc*nz);
                Transform t3d(Dict("type","eman","az",(float)-25.0));
                insert_rectangle(image, region, 0.4f, t3d);
        }

        // Rotated ellipsoids
        {
                Transform t;
                t.set_trans(nx*6.8f*xinc-nx/2,ny*16*yinc-ny/2,0);
                Dict rot;
                rot["type"] = "eman";
                rot["az"] = 43.0f;
                t.set_rotation(rot);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1.5*xinc*nx;
                d["b"] = (float) .5*yinc*ny;
                d["c"] = (float) .5*zinc*nz;
                d["fill"] = 0.2;
                image->process_inplace("testimage.ellipsoid",d);
        }
        {
                Transform t;
                t.set_trans(nx*7.2f*xinc-nx/2,ny*16*yinc-ny/2,0);
                Dict rot;
                rot["type"] = "eman";
                rot["az"] = 135.0f;
                t.set_rotation(rot);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) 1.5*xinc*nx;
                d["b"] = (float) .5*yinc*ny;
                d["c"] = (float) .5*zinc*nz;
                d["fill"] = 0.3;
                image->process_inplace("testimage.ellipsoid",d);
        }

        // Dense small ellipsoids
        {
                Transform t;
                t.set_trans(nx*3.5f*xinc-nx/2,ny*8*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) .5*xinc*nx;
                d["b"] = (float) .5*yinc*ny;
                d["c"] = (float) .5*zinc*nz;
                d["fill"] = 2.05;
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*8*xinc-nx/2,ny*18*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*14*xinc-nx/2,ny*18.2f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*18*xinc-nx/2,ny*14*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*17*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);
        }


        // Dense small rectangles
        {
                Region region(nx*18.*inc,ny*11.5*inc,nz/2.,1.*inc*nx,1.*inc*ny,1.*inc*nz);
                Transform t3d(Dict("type","eman","az",(float)45.0));
                insert_rectangle(image, region, 1.45f, t3d);
        }
        {
                Region region(nx*3.*inc,ny*10.5*inc,nz/2.,1.*inc*nx,1.*inc*ny,1.*inc*nz);
                Transform t3d(Dict("type","eman","az",(float)45.0));
                insert_rectangle(image, region, 1.45f, t3d);
        }

        // Insert small cluster of spheres
        {
                Transform t;
                t.set_trans(nx*14*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) .5*xinc*nx;
                d["b"] = (float) .5*yinc*ny;
                d["c"] = (float) .5*zinc*nz;
                d["fill"] = .35;
                image->process_inplace("testimage.ellipsoid",d);
        }
        {
                Transform t;
                t.set_trans(nx*15*xinc-nx/2,ny*7.5f*yinc-ny/2,0);
                Dict d;
                d["transform"] = &t;
                d["a"] = (float) .25*xinc*nx;
                d["b"] = (float) .25*yinc*ny;
                d["c"] = (float) .25*zinc*nz;
                d["fill"] = .35;
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*13.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*14.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*15.5f*xinc-nx/2,ny*6.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*14*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*14*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*15*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*16*xinc-nx/2,ny*5.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*14.5f*xinc-nx/2,ny*4.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);

                t.set_trans(nx*15.5f*xinc-nx/2,ny*4.5f*yinc-ny/2,0);
                image->process_inplace("testimage.ellipsoid",d);
        }
        // Insert feducials around the outside of the "cell"
//      for ( float i = 0.; i < 3.; i += 1. ) {
//              for ( float j = 0.; j < 3.; j += 1. ) {
//                      Region region(nx*2.+i*inc,ny*2.+j*inc,nz/2.,0.05*inc*nx,0.05*inc*ny,0.05*inc*nz);
//                      insert_solid_ellipse(image, region, 2.0);
//              }
//      }

}

Member Data Documentation

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

Definition at line 6486 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: