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:

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 1216 of file emdata_metadata.cpp.

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

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

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

int greaterthan ( const void *  p1,
const void *  p2 
)

Definition at line 922 of file emdata_metadata.cpp.

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

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


Generated on Mon Mar 7 17:59:25 2011 for EMAN2 by  doxygen 1.4.7