EMAN2
Functions
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 1347 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().

{
        static vector<Vec3i> two_six_connected;
        if (two_six_connected.size() == 0) {
                for(int i = -1; i <= 1; ++i) {
                        for(int j = -1; j <= 1; ++j) {
                                for(int  k = -1; k <= 1; ++k) {
                                        if ( j != 0 || i != 0 || k != 0) {
                                                two_six_connected.push_back(Vec3i(i,j,k));
                                        }
                                }
                        }
                }
        }

        vector<Vec3i> ret;
        for(vector<Vec3i>::const_iterator it = two_six_connected.begin(); it != two_six_connected.end(); ++it ) {
                for(vector<Vec3i>::const_iterator it2 = coords.begin(); it2 != coords.end(); ++it2 ) {
                        if  (image->get_value_at((*it2)[0],(*it2)[1],(*it2)[2]) != value) throw;
                        Vec3i c = (*it)+(*it2);

                        if ( c[0] < 0 || c[0] >= image->get_xsize()) continue;
                        if ( c[1] < 0 || c[1] >= image->get_ysize()) continue;
                        if ( c[2] < 0 || c[2] >= image->get_zsize()) continue;

                        if( image->get_value_at(c[0],c[1],c[2]) == value ) {
                                if (find(ret.begin(),ret.end(),c) == ret.end()) {
                                        if (find(region.begin(),region.end(),c) == region.end()) {
                                                region.push_back(c);
                                                ret.push_back(c);
                                        }
                                }
                        }
                }
        }
        return ret;
}
int greaterthan ( const void *  p1,
const void *  p2 
)

Definition at line 1053 of file emdata_metadata.cpp.

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

{
        float*  v1 = (float*) p1;
        float*  v2 = (float*) p2;

        if ( *v1 < *v2 )  return 0;
        else return 1;
}