EMAN2
Public Member Functions | Private Attributes | List of all members
EMAN::TomoSeg Class Reference

#include <tomoseg.h>

Collaboration diagram for EMAN::TomoSeg:
Collaboration graph
[legend]

Public Member Functions

 TomoSeg ()
 
void set_verb ()
 
int read_bwmap (EMData *map)
 
int read_skelmap (EMData *map)
 
int generate_objects (int numo, float maxdist, int nowslice)
 
int check_neighbors (int x, int y)
 
void write_imod (const char *file)
 

Private Attributes

EMDataskelmap
 
EMDatabwmap
 
bool verb
 
vector< TomoObjectobjs
 

Detailed Description

Definition at line 55 of file tomoseg.h.

Constructor & Destructor Documentation

◆ TomoSeg()

EMAN::TomoSeg::TomoSeg ( )
inline

Definition at line 58 of file tomoseg.h.

58{verb=false;};
bool verb
Definition: tomoseg.h:79

References verb.

Member Function Documentation

◆ check_neighbors()

int TomoSeg::check_neighbors ( int  x,
int  y 
)

Definition at line 209 of file tomoseg.cpp.

209 {
210 int nb=-1;
211 for (int i=-1; i<=1; i++){
212 for (int j=-1; j<=1; j++){
213 nb+= (skelmap->get_value_at(x+i,y+j)>0 ? 1 : 0);
214 }
215 }
216 return nb;
217}
EMData * skelmap
Definition: tomoseg.h:77
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References skelmap, x, and y.

Referenced by generate_objects().

◆ generate_objects()

int TomoSeg::generate_objects ( int  numo,
float  maxdist,
int  nowslice 
)

Definition at line 145 of file tomoseg.cpp.

145 {
146 if (!skelmap){
147 printf("No map input.\n");
148 return 0;
149 }
150
151 // Calculate area of each segment
152 EMData *rank=skelmap->process("threshold.notzero");
153 rank->process_inplace("morph.object.density",Dict("thresh",0,"more_neighbor",true));
154 int nx=rank->get_xsize();
155 int ny=rank->get_ysize();
156
157 // Take numo largest objects
158 for (int i=0; i<numo; i++){
159 float max=rank->get_attr("maximum");
160 vector <Vec3i> pts;
161 float curid=-1;
162 bool branch=false;
163 if (max<=0)
164 break;
165 for (int x=0; x<nx; x++){
166 for (int y=0; y<ny; y++){
167 if (rank->get_value_at(x,y)==max){
168 if (curid<0)
169 curid=skelmap->get_value_at(x,y);
170 if (curid==skelmap->get_value_at(x,y)){
171 int nb=check_neighbors(x,y);
172 if (nb>2) branch=true;
173 pts.push_back(Vec3i(x,y,nb));
174 rank->set_value_at_fast(x,y,0);
175 }
176 }
177 }
178 }
179 if(verb) printf("id=%d, size=%d",int(curid),int(pts.size()));
180 if (branch){
181 if (verb) printf("\n\thave branch, throw out.\n");
182 }
183 else{
184 objs.push_back(TomoObject(pts,maxdist,nowslice));
185 if (verb) printf(" \t%d points\n",objs.back().get_size() );
186 }
187
188 }
189
190 delete rank;
191 return 1;
192}
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
int check_neighbors(int x, int y)
Definition: tomoseg.cpp:209
vector< TomoObject > objs
Definition: tomoseg.h:80
Vec3< int > Vec3i
Definition: vec3.h:694

References check_neighbors(), objs, skelmap, verb, x, and y.

◆ read_bwmap()

int EMAN::TomoSeg::read_bwmap ( EMData map)

◆ read_skelmap()

int TomoSeg::read_skelmap ( EMData map)

Definition at line 138 of file tomoseg.cpp.

138 {
139 if (!map)
140 return 0;
141 skelmap=map;
142 return 1;
143}

References skelmap.

◆ set_verb()

void EMAN::TomoSeg::set_verb ( )
inline

Definition at line 59 of file tomoseg.h.

59{verb=!verb;};

References verb.

◆ write_imod()

void TomoSeg::write_imod ( const char *  file)

Definition at line 194 of file tomoseg.cpp.

194 {
195 FILE *fp = fopen(file, "w");
196 int nx=skelmap->get_xsize();
197 int ny=skelmap->get_ysize();
198 int nz=skelmap->get_zsize();
199 fprintf(fp,"imod %d\n",(int)objs.size());
200 fprintf(fp,"max %d %d %d\n",nx,ny,nz);
201 for (int i=0; i<(int)objs.size(); i++){
202 fprintf(fp,"object %d 1 0\n",i);
203 objs[i].write_imod(fp);
204 fprintf(fp,"\n");
205 }
206 fclose(fp);
207}

References objs, and skelmap.

Member Data Documentation

◆ bwmap

EMData* EMAN::TomoSeg::bwmap
private

Definition at line 78 of file tomoseg.h.

◆ objs

vector<TomoObject> EMAN::TomoSeg::objs
private

Definition at line 80 of file tomoseg.h.

Referenced by generate_objects(), and write_imod().

◆ skelmap

EMData* EMAN::TomoSeg::skelmap
private

Definition at line 77 of file tomoseg.h.

Referenced by check_neighbors(), generate_objects(), read_skelmap(), and write_imod().

◆ verb

bool EMAN::TomoSeg::verb
private

Definition at line 79 of file tomoseg.h.

Referenced by generate_objects(), set_verb(), and TomoSeg().


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