EMAN2
Functions
emdata_metadata.cpp File Reference
#include "emdata.h"
#include "ctf.h"
#include "portable_fileio.h"
#include "io/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

◆ find_region()

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

Definition at line 1344 of file emdata_metadata.cpp.

1345{
1346 static vector<Vec3i> two_six_connected;
1347 if (two_six_connected.size() == 0) {
1348 for(int i = -1; i <= 1; ++i) {
1349 for(int j = -1; j <= 1; ++j) {
1350 for(int k = -1; k <= 1; ++k) {
1351 if ( j != 0 || i != 0 || k != 0) {
1352 two_six_connected.push_back(Vec3i(i,j,k));
1353 }
1354 }
1355 }
1356 }
1357 }
1358
1359 vector<Vec3i> ret;
1360 for(vector<Vec3i>::const_iterator it = two_six_connected.begin(); it != two_six_connected.end(); ++it ) {
1361 for(vector<Vec3i>::const_iterator it2 = coords.begin(); it2 != coords.end(); ++it2 ) {
1362 if (image->get_value_at((*it2)[0],(*it2)[1],(*it2)[2]) != value) throw;
1363 Vec3i c = (*it)+(*it2);
1364
1365 if ( c[0] < 0 || c[0] >= image->get_xsize()) continue;
1366 if ( c[1] < 0 || c[1] >= image->get_ysize()) continue;
1367 if ( c[2] < 0 || c[2] >= image->get_zsize()) continue;
1368
1369 if( image->get_value_at(c[0],c[1],c[2]) == value ) {
1370 if (find(ret.begin(),ret.end(),c) == ret.end()) {
1371 if (find(region.begin(),region.end(),c) == region.end()) {
1372 region.push_back(c);
1373 ret.push_back(c);
1374 }
1375 }
1376 }
1377 }
1378 }
1379 return ret;
1380}
Vec3< int > Vec3i
Definition: vec3.h:694

◆ greaterthan()

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

Definition at line 996 of file emdata_metadata.cpp.

997{
998 float* v1 = (float*) p1;
999 float* v2 = (float*) p2;
1000
1001 if ( *v1 < *v2 ) return 0;
1002 else return 1;
1003}

Referenced by get_attr().