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 1345 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().

01346 {
01347         static vector<Vec3i> two_six_connected;
01348         if (two_six_connected.size() == 0) {
01349                 for(int i = -1; i <= 1; ++i) {
01350                         for(int j = -1; j <= 1; ++j) {
01351                                 for(int  k = -1; k <= 1; ++k) {
01352                                         if ( j != 0 || i != 0 || k != 0) {
01353                                                 two_six_connected.push_back(Vec3i(i,j,k));
01354                                         }
01355                                 }
01356                         }
01357                 }
01358         }
01359 
01360         vector<Vec3i> ret;
01361         for(vector<Vec3i>::const_iterator it = two_six_connected.begin(); it != two_six_connected.end(); ++it ) {
01362                 for(vector<Vec3i>::const_iterator it2 = coords.begin(); it2 != coords.end(); ++it2 ) {
01363                         if  (image->get_value_at((*it2)[0],(*it2)[1],(*it2)[2]) != value) throw;
01364                         Vec3i c = (*it)+(*it2);
01365 
01366                         if ( c[0] < 0 || c[0] >= image->get_xsize()) continue;
01367                         if ( c[1] < 0 || c[1] >= image->get_ysize()) continue;
01368                         if ( c[2] < 0 || c[2] >= image->get_zsize()) continue;
01369 
01370                         if( image->get_value_at(c[0],c[1],c[2]) == value ) {
01371                                 if (find(ret.begin(),ret.end(),c) == ret.end()) {
01372                                         if (find(region.begin(),region.end(),c) == region.end()) {
01373                                                 region.push_back(c);
01374                                                 ret.push_back(c);
01375                                         }
01376                                 }
01377                         }
01378                 }
01379         }
01380         return ret;
01381 }

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

Definition at line 1050 of file emdata_metadata.cpp.

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

01051 {
01052         float*  v1 = (float*) p1;
01053         float*  v2 = (float*) p2;
01054 
01055         if ( *v1 < *v2 )  return 0;
01056         else return 1;
01057 }


Generated on Tue Jun 11 12:40:51 2013 for EMAN2 by  doxygen 1.4.7