/** * Get an ordered vector of particles for the image. * Create a vector of particle analysis reports sorted by size for an image. * The vector contains the actual report structures. * @returns a pointer to the vector of particle analysis reports. The caller must delete the * vector when finished using it. */ vector<ParticleAnalysisReport>* BinaryImage::GetOrderedParticleAnalysisReports() { vector<ParticleAnalysisReport>* particles = new vector<ParticleAnalysisReport>; int particleCount = GetNumberParticles(); for(int particleIndex = 0; particleIndex < particleCount; particleIndex++) { particles->push_back(GetParticleAnalysisReport(particleIndex)); } sort(particles->begin(), particles->end(), compareParticleSizes); return particles; }
/** * Get an ordered vector of particles for the image. * Create a vector of particle analysis reports sorted by size for an image. * The vector contains the actual report structures. * @returns a pointer to the vector of particle analysis reports. The caller must delete the * vector when finished using it. */ vector<ParticleAnalysisReport>* BinaryImage::GetOrderedParticleAnalysisReports() { vector<ParticleAnalysisReport>* particles = new vector<ParticleAnalysisReport>; int particleCount = GetNumberParticles(); for(int particleIndex = 0; particleIndex < particleCount; particleIndex++) { particles->push_back(GetParticleAnalysisReport(particleIndex)); } // TODO: This is pretty inefficient since each compare in the sort copies // both reports being compared... do it manually instead... while we're // at it, we should provide a version that allows a preallocated buffer of // ParticleAnalysisReport structures sort(particles->begin(), particles->end(), CompareParticleSizes); return particles; }
/** * Get a single particle analysis report. * Get one (of possibly many) particle analysis reports for an image. * @param particleNumber Which particle analysis report to return. * @returns the selected particle analysis report */ ParticleAnalysisReport BinaryImage::GetParticleAnalysisReport(int particleNumber) { ParticleAnalysisReport par; GetParticleAnalysisReport(particleNumber, &par); return par; }