Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

emdata_metadata.cpp File Reference

#include "emdata.h"
#include "ctf.h"
#include "portable_fileio.h"
#include "imageio.h"
#include <cstring>
#include <sstream>
#include <iomanip>
#include <sys/stat.h>
#include <iostream>

Include dependency graph for emdata_metadata.cpp:

Include dependency graph

Go to the source code of this file.

Functions

int greaterthan (const void *p1, const void *p2)
vector< Vec3ifind_region (EMData *image, const vector< Vec3i > &coords, const float value, vector< Vec3i > &region)


Function Documentation

vector<Vec3i > find_region EMData image,
const vector< Vec3i > &  coords,
const float  value,
vector< Vec3i > &  region
 

Definition at line 1215 of file emdata_metadata.cpp.

References EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), and EMAN::Vec3i.

Referenced by EMAN::EMData::mask_contig_region().

01216 {
01217         static vector<Vec3i> two_six_connected;
01218         if (two_six_connected.size() == 0) {
01219                 for(int i = -1; i <= 1; ++i) {
01220                         for(int j = -1; j <= 1; ++j) {
01221                                 for(int  k = -1; k <= 1; ++k) {
01222                                         if ( j != 0 || i != 0 || k != 0) {
01223                                                 two_six_connected.push_back(Vec3i(i,j,k));
01224                                         }
01225                                 }
01226                         }
01227                 }
01228         }
01229 
01230         vector<Vec3i> ret;
01231         for(vector<Vec3i>::const_iterator it = two_six_connected.begin(); it != two_six_connected.end(); ++it ) {
01232                 for(vector<Vec3i>::const_iterator it2 = coords.begin(); it2 != coords.end(); ++it2 ) {
01233                         if  (image->get_value_at((*it2)[0],(*it2)[1],(*it2)[2]) != value) throw;
01234                         Vec3i c = (*it)+(*it2);
01235 
01236                         if ( c[0] < 0 || c[0] >= image->get_xsize()) continue;
01237                         if ( c[1] < 0 || c[1] >= image->get_ysize()) continue;
01238                         if ( c[2] < 0 || c[2] >= image->get_zsize()) continue;
01239 
01240                         if( image->get_value_at(c[0],c[1],c[2]) == value ) {
01241                                 if (find(ret.begin(),ret.end(),c) == ret.end()) {
01242                                         if (find(region.begin(),region.end(),c) == region.end()) {
01243                                                 region.push_back(c);
01244                                                 ret.push_back(c);
01245                                         }
01246                                 }
01247                         }
01248                 }
01249         }
01250         return ret;
01251 }

int greaterthan const void *  p1,
const void *  p2
 

Definition at line 921 of file emdata_metadata.cpp.

Referenced by EMAN::EMData::get_attr().

00922 {
00923         float*  v1 = (float*) p1;
00924         float*  v2 = (float*) p2;
00925 
00926         if ( *v1 < *v2 )  return 0;
00927         else return 1;
00928 }


Generated on Thu Dec 9 13:46:07 2010 for EMAN2 by  doxygen 1.3.9.1