EMAN2
emdata_modular.cpp
Go to the documentation of this file.
1/*
2 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#include "emdata.h"
33#include "processor.h"
34#include "cmp.h"
35#include "aligner.h"
36#include "projector.h"
37#include "analyzer.h"
38
39using namespace EMAN;
40
41void EMData::process_inplace(const string & processorname, const Dict & params)
42{
44 Processor *f = Factory < Processor >::get(processorname, params);
45 if (f) {
46 f->process_inplace(this);
47 if( f )
48 {
49 delete f;
50 f = 0;
51 }
52 }
54}
55
57{
59 if(p) {
60 p->process_inplace(this);
61 }
63}
64
65EMData* EMData::process(const string & processorname, const Dict & params) const
66{
68 Processor *f = Factory < Processor >::get(processorname, params);
69 EMData * result = 0;
70 if (f) {
71 result = f->process(this);
72 if( f )
73 {
74 delete f;
75 f = 0;
76 }
77 }
78 return result;
80}
81
83{
85 EMData * result = 0;
86 if(p) {
87 result = p->process(this);
88 }
89 return result;
91}
92
93float EMData::cmp(const string & cmpname, EMData * with, const Dict & params)
94{
96 float result = 0;
97 Cmp *c = Factory < Cmp >::get(cmpname, params);
98 if (c) {
99 result = c->cmp(this, with);
100 if( c )
101 {
102 delete c;
103 c = 0;
104 }
105 }
106
107 EXITFUNC;
108 return result;
109}
110
111
112EMData *EMData::align(const string & aligner_name, EMData * to_img,
113 const Dict & params, const string & cmp_name, const Dict& cmp_params)
114{
115 ENTERFUNC;
116 EMData *result = 0;
117 Aligner *a = Factory < Aligner >::get(aligner_name, params);
118 if (a) {
119 if (cmp_name == "") {
120 result = a->align(this, to_img);
121 }
122 else {
123 result = a->align(this, to_img, cmp_name, cmp_params);
124 }
125 if( a )
126 {
127 delete a;
128 a = 0;
129 }
130 }
131
132 EXITFUNC;
133 return result;
134}
135
136vector<Dict> EMData::xform_align_nbest(const string & aligner_name, EMData * to_img,
137 const Dict & params, const unsigned int nsoln, const string & cmp_name,
138 const Dict& cmp_params)
139{
140 ENTERFUNC;
141 Aligner *a = Factory < Aligner >::get(aligner_name, params);
142 vector<Dict> result;
143 if (a) {
144 result = a->xform_align_nbest(this,to_img,nsoln,cmp_name,cmp_params);
145 }
146
147 return result;
148}
149
150EMData *EMData::project(const string & projector_name, const Dict & params)
151{
152 ENTERFUNC;
153 EMData *result = 0;
154 Projector *p = Factory < Projector >::get(projector_name, params);
155 if (p) {
156 result = p->project3d(this);
157 if( p )
158 {
159 delete p;
160 p = 0;
161 }
162 }
163
164 EXITFUNC;
165 return result;
166}
167
168
169EMData *EMData::project(const string & projector_name, const Transform & t3d)
170{
171 ENTERFUNC;
172 EMData *result = 0;
173 Dict params;
174 params["transform"] = (Transform*) &t3d;
175 Projector *p = Factory < Projector >::get(projector_name, params);
176 if (p) {
177 result = p->project3d(this);
178 if( p )
179 {
180 delete p;
181 p = 0;
182 }
183 }
184
185 EXITFUNC;
186 return result;
187}
188
189EMData *EMData::backproject(const string & projector_name, const Dict & params)
190{
191 ENTERFUNC;
192 EMData *result = 0;
193 Projector *p = Factory < Projector >::get(projector_name, params);
194 if (p) {
195 result = p->backproject3d(this);
196 if( p )
197 {
198 delete p;
199 p = 0;
200 }
201 }
202
203 EXITFUNC;
204 return result;
205}
Aligner class defines image alignment method.
Definition: aligner.h:81
virtual vector< Dict > xform_align_nbest(EMData *this_img, EMData *to_img, const unsigned int nsoln, const string &cmp_name, const Dict &cmp_params) const
This function first added in the context of the 3D aligners used by e2tomohunter: which wants the n b...
Definition: aligner.cpp:135
virtual EMData * align(EMData *this_img, EMData *to_img) const =0
Cmp class defines image comparison method.
Definition: cmp.h:82
virtual float cmp(EMData *image, EMData *with) const =0
To compare 'image' with another image passed in through its parameters.
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
Factory is used to store objects to create new instances.
Definition: emobject.h:725
Typical usage of Processors are as follows:
Definition: processor.h:90
virtual EMData * process(const EMData *const image)
To proccess an image out-of-place.
Definition: processor.cpp:637
virtual void process_inplace(EMData *image)=0
To process an image in-place.
Projector class defines a method to generate 2D projections from a 3D model.
Definition: projector.h:78
virtual EMData * backproject3d(EMData *image) const =0
Back-project a 2D image into a 3D image.
virtual EMData * project3d(EMData *image) const =0
Project an 3D image into a 2D image.
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
vector< Dict > xform_align_nbest(const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const unsigned int nsoln=1, const string &cmp_name="dot", const Dict &cmp_params=Dict())
Align this image with another image, return the parameters of the "n best" solutions See Aligner::xfo...
EMData * backproject(const string &projector_name, const Dict &params=Dict())
Calculate the backprojection of this image (stack) and return the result.
float cmp(const string &cmpname, EMData *with, const Dict &params=Dict())
Compare this image with another image.
EMData * process(const string &processorname, const Dict &params=Dict()) const
Apply a processor with its parameters on a copy of this image, return result as a a new image.
void process_inplace(const string &processorname, const Dict &params=Dict())
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
EMData * project(const string &projector_name, const Dict &params=Dict())
Calculate the projection of this image and return the result.
EMData * align(const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const string &cmp_name="", const Dict &cmp_params=Dict())
Align this image with another image and return the result image.
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49
E2Exception class.
Definition: aligner.h:40