本文整理汇总了C++中Segmentation类的典型用法代码示例。如果您正苦于以下问题:C++ Segmentation类的具体用法?C++ Segmentation怎么用?C++ Segmentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Segmentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
get_ngram().read(argc == 2 ? argv[1] : "ngram");
dic_init();
warch.load("wordlist");
int count = 0;
while (!cin.eof()) {
if (++count % 200 == 0) cerr << count << endl;
Lattice l;
cin >> l;
WordDAG dag(&l);
Path p;
PFS pfs;
pfs.search(dag,p);
Segmentation seg;
if (p.empty() || p.size() <= 2)
continue;
seg.resize(p.size()-2);
copy(p.begin()+1,p.end()-1,seg.begin());
seg.we = l.we;
cout << seg << endl;
}
return 0;
}
示例2: Chromagram
KeyDetectionResult KeyFinder::keyOfChromagram(
Workspace& workspace,
const Parameters& params
) const {
KeyDetectionResult result;
// working copy of chromagram
Chromagram* ch = new Chromagram(*workspace.chroma);
ch->reduceToOneOctave();
// get harmonic change signal and segment
Segmentation segmenter;
std::vector<unsigned int> segmentBoundaries = segmenter.getSegmentationBoundaries(ch, params);
segmentBoundaries.push_back(ch->getHops()); // sentinel
// get key estimates for each segment
KeyClassifier classifier(
params.getSimilarityMeasure(),
params.getToneProfile(),
params.getOffsetToC(),
params.getCustomToneProfile()
);
std::vector<float> keyWeights(24); // TODO: not ideal using int cast of key_t enum. Hash?
for (int s = 0; s < (signed) segmentBoundaries.size() - 1; s++) {
KeyDetectionResultSegment segment;
segment.firstHop = segmentBoundaries[s];
segment.lastHop = segmentBoundaries[s+1] - 1;
// collapse segment's time dimension
std::vector<float> segmentChroma(ch->getBands(), 0.0);
for (unsigned int hop = segment.firstHop; hop <= segment.lastHop; hop++) {
for (unsigned int band = 0; band < ch->getBands(); band++) {
float value = ch->getMagnitude(hop, band);
segmentChroma[band] += value;
segment.energy += value;
}
}
segment.chromaVector = segmentChroma;
segment.key = classifier.classify(segmentChroma);
if (segment.key != SILENCE)
keyWeights[segment.key] += segment.energy;
result.segments.push_back(segment);
}
delete ch;
// get global key
result.globalKeyEstimate = SILENCE;
float mostCommonKeyWeight = 0.0;
for (int k = 0; k < (signed)keyWeights.size(); k++) {
if (keyWeights[k] > mostCommonKeyWeight) {
mostCommonKeyWeight = keyWeights[k];
result.globalKeyEstimate = (key_t)k;
}
}
return result;
}
示例3: RETURN_IF_UID_NOT_VALID
bool ModelValidator::isValid(const Segmentation& segmentation, bool allowDefaults/* = false*/)
{
RETURN_IF_UID_NOT_VALID(segmentation.GetSopInstanceUID(), "SOP Instance UID");
RETURN_IF_UID_NOT_VALID(segmentation.GetSopClassUID(), "SOP Class UID");
RETURN_IF_UID_NOT_VALID(segmentation.GetReferencedSopInstanceUID(), "Referenced SOP Instance UID");
if (segmentation.GetImagingObservation() != NULL)
RETURN_IF_NOT_VALID1(*segmentation.GetImagingObservation(), allowDefaults, "Segmentation's Imaging Observation is invalid");
return true;
}
示例4: getViewer
void Tools::segmentation()
{
ImageViewer* iv = getViewer();
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
<< QImage::Format_RGB32))
return;
Segmentation* s = new Segmentation(iv->getImage(), iv);
s->start();
}
示例5: while
void WFST::generate_misspelled_words(const vector<uint> &pos,int len,Segmentation &final_seg)
{
const Lattice &words = *p_words;
Lattice w;
w.based_on(words);
// 2. Compute the score, jump to 1. if score is too low (pruning 1)
// create new (more compact) Lattice structure
int i,n = words.get_word_count();
for (i = 0;i < len;i ++) {
const WordEntryRefs &fmap = words.get_fuzzy_map(pos[i]);
int ii,nn = fmap.size();
for (ii = 0;ii < nn;++ii)
w.add(*fmap[ii]);
}
//cerr << w << endl;
// 4. Create sections
Sections sects;
sects.construct(words);
// 5. Call create_base_segmentation
//Segmentation base_seg(words.we);
//create_base_segmentation(words,sects,base_seg);
// 6. Get the best segmentation of each section,
// then merge to one big segment.
n = sects.size();
uint ii,nn;
i = ii = 0;
nn = words.get_word_count();
final_seg.clear();
while (ii < nn)
if (i < n && sects[i].start == ii) {
Segmentation seg;
sects[i].segment_best(words,seg);
copy(seg.begin(),
seg.end(),
back_insert_iterator< Segmentation >(final_seg));
ii += sects[i].len;
i ++;
} else {
// only word(i,*,0) exists
final_seg.push_back(words.get_we(ii)[0]->id);
ii += words.get_we(ii)[0]->len;
}
}
示例6: main
int
main (int argc, char **argv)
{
bool use_device = false;
bool use_file = false;
if (argc >= 2)
use_device = true;
if (argc >= 3)
use_file = true;
Segmentation s;
s.run (use_device, use_file);
return 0;
}
示例7: main
int
main (int argc, char **argv)
{
ros::init (argc, argv, "realtime_segmentation");
ros::NodeHandle nh ("~");
bool gui = false;
if (command_line_param (argc, argv, "--gui"))
gui = true;
Segmentation s (nh, gui);
s.run ();
return 0;
}
示例8: h
long long Geant4SensitiveDetector::getCellID(G4Step* s) {
StepHandler h(s);
Geant4VolumeManager volMgr = Geant4Mapping::instance().volumeManager();
VolumeID volID = volMgr.volumeID(h.preTouchable());
Segmentation seg = m_readout.segmentation();
if ( seg.isValid() ) {
G4ThreeVector global = 0.5 * ( h.prePosG4()+h.postPosG4());
G4ThreeVector local = h.preTouchable()->GetHistory()->GetTopTransform().TransformPoint(global);
Position loc(local.x()*MM_2_CM, local.y()*MM_2_CM, local.z()*MM_2_CM);
Position glob(global.x()*MM_2_CM, global.y()*MM_2_CM, global.z()*MM_2_CM);
VolumeID cID = seg.cellID(loc,glob,volID);
return cID;
}
return volID;
}
示例9: getHypseg
ReturnType Recognizer::getHypseg(Segmentation& seg) {
if ((decoder == NULL) || (is_recording)) return BAD_STATE;
seg.clear();
int32 scoreh=0, sfh=0, efh=0;
std::string hseg;
ps_seg_t *itor = ps_seg_iter(decoder, &scoreh);
while (itor) {
SegItem segItem;
segItem.word = ps_seg_word(itor);
ps_seg_frames(itor, &sfh, &efh);
segItem.start = sfh;
segItem.end = efh;
seg.push_back(segItem);
itor = ps_seg_next(itor);
}
return SUCCESS;
}
示例10: main
int main(int argc, char** argv)
{
const std::string sourcePath = "IMG_0267.jpg";
const std::string destPath = "test.bmp";
// Basic procedure to use the library
ColorimetricYCbCrAlgorithm1<NumType> algo = ColorimetricYCbCrAlgorithm1<NumType>();
// Algorithm configuration
algo.ApplyMedian(true);
algo.MedianSize(3);
algo.ApplyGrow(true);
algo.GrowCount(20);
algo.GrowSize(3);
algo.ApplyShrink(true);
algo.ShrinkCount(22);
algo.ShrinkSize(3);
algo.ApplyFixedGrowShrink(false);
algo.FixedGrowShrinkCount(10);
algo.FixedGrowShrinkSize(5);
algo.ApplyRegionClearing(true);
Segmentation<NumType> segm = Segmentation<NumType>(&algo);
CImg<bool> *mask = segm.retrieveMask_asBinaryChannel(sourcePath);
CImg<int> *distMap = segm.retrieveDistanceMapOfMask(*mask);
CImg<unsigned char> *resImg = distanceMapToRGB(distMap);
//CImg<int> *resImg = changeBinaryMaskToRGBImage(*mask);
/*std::vector<BinarySeed> *skinSeeds = segm.retrieveSkinSeedsOfMask(*testImg, true, true, 30, 5);
std::vector<BinarySeed> *nonSkinSeeds = segm.retrieveNonSkinSeedsOfMask(*testImg, true, true, 30, 5);
addSeedsToRGBImage(resImg,skinSeeds,nonSkinSeeds);*/
resImg->save(destPath.c_str());
delete mask;
delete resImg;
delete distMap;
return 0;
}
示例11: finalise
void TonalAnalyser::finalise(TrackInfoObject* tio) {
if(!m_bCanRun)
return;
CLAM::DiscontinuousSegmentation segmentation = m_ce.segmentation();
Segmentation<QString> segs;
for (unsigned i=0; i<segmentation.onsets().size(); i++)
{
unsigned chordIndex = m_ce.chordIndexes()[i];
std::string chordName = m_ce.root(chordIndex) + " " + m_ce.mode(chordIndex);
//segmentation.setLabel(i,chordName);
segs.addSeg(segmentation.onsets()[i], segmentation.offsets()[i], chordName.c_str());
//qDebug() << "Got chord " << chordName.c_str() << " at " << segmentation.onsets()[i] << " until " << segmentation.offsets()[i];
}
m_ce.clear();
tio->setChordData(segs);
}
示例12: GiveSegImgPath
/*******************************************************************
* Function Name: GetSegments
* Return Type : int
* Created On : Jan 1, 2013
* Created By : hrushi
* Comments : Gets the Segments of objects
*******************************************************************/
ContourMap Detect::GetSegments( const ColorImg ProbeImg, const GrayImg BkImg, bool bSaveOutput, const Args& args )
{
fs::path iPath = ProbeImg.GetImagePath();
fs::path OutputPath;
OutputPath = GiveSegImgPath(iPath, "_seg");
ContourMap Cnturs;
for( int K = SLIC_K; K >= 1; K-- )
{
try
{
Segmentation Segm;
Cnturs = Segm.GetSegments(ProbeImg, BkImg, OutputPath.string(), bSaveOutput, K, SLIC_M, args );
}
catch(int iERR)
{
if( iERR == ERR_SLIC )
{
cerr << "Calling Slick with K: " << (K - 1) << endl;
continue;
}
}
break;
}
if(bSaveOutput)
{
ColorImg Overlay = ProbeImg.Overlay(Cnturs, 1, cv::Scalar(0, 0, 255), args);
string OverlayWrite = GiveSegImgPath(iPath, "_Merge").string();
Overlay.Write( OverlayWrite );
}
return Cnturs;
}
示例13: computeFirefly
void FireflyOptimizator::computeFirefly(Segmentation ffI, int idx_ffI, int verbose = 3)
{
if(verbose >=1 ) {
cout << "------------------------------" << endl;
cout << "Starting " << idx_ffI << endl;
}
double rank1 = ranks[idx_ffI];
int j = 0,idx_ffJ =0 ;
vector<Segmentation>::iterator ffJ;
for( ffJ = population.begin(),idx_ffJ=0; ffJ != population.end();idx_ffJ++,ffJ++) {
if (idx_ffI == idx_ffJ) {
j++;
continue;
}
double rank2 = ranks[idx_ffJ];
if(verbose >=2 )
cout << "\tComparing " << idx_ffI << " with " << j << " (" << rank1 << " x " << rank2 << " ) ";
if (rank2 > rank1) {
double distance = getDistance(ffI, *ffJ);
double amount = beta * exp(-gamma * distance * distance);
if(verbose >= 3)
cout << " - Dis: " << distance << " It: " << amount;
ffI.matrixAdj = ffI.interpolateMatrix(*ffJ, amount);
j++;
}
else
{ if(verbose >=3 )
cout<<" - "<<idx_ffI << " greater, no update.";
}
//cout<<endl;
}
}
示例14: getDistance
double FireflyOptimizator::getDistance(Segmentation pr, Segmentation gt)
{
double dis = 0.0;
for(int i=0;i<pr.size;i++) {
int top = (i-pr.width)<0?-1:i-pr.width;
int down = (i+pr.width) >= pr.width* pr.height ? -1 : i+pr.width;
int left = (i-1)<0?-1:i-1;
int right = (i+1)>= pr.height*pr.width?-1:i+1;
if (top!=-1)
{
dis += abs(pr.findWeight(i, top) - gt.findWeight(i, top));
}
if (down!=-1)
{
dis += abs(pr.findWeight(i, down) - gt.findWeight(i, down));
}
if (right!=-1)
{
dis += abs(pr.findWeight(i, right) - gt.findWeight(i, right));
}
if (left!=-1) {
dis += abs(pr.findWeight(i, left) - gt.findWeight(i, left));
}
}
return dis;
}
示例15: print_area_center
void print_area_center(Segmentation& seg, const std::string& name, int label, Image& output) {
int area; Coordinate center;
seg.GetCenterAndArea(label, center, area);
std::cout << name << " is located at " << center.GetX() << ", " << center.GetY() << " with area " << area << std::endl;
Coordinate point(seg.GetLabelTopLeft(label));
std::vector<int> freeman_code;
seg.GetFreemanCode(label, point, freeman_code);
seg.DrawContourFreeman(point, freeman_code, Color::red(), output);
const float circumference = seg.GetCircumference(freeman_code);
const float roundness = seg.GetRoundness(area, circumference);
std::cout << " Object has roundness of " << roundness << std::endl;
if (rint(roundness) >= 45) {
std::cout << " Object is a tree" << std::endl;
} else if (rint(roundness) >= 16) {
std::cout << " Object is a rectangle" << std::endl;
} else {
std::cout << " Object is a circle" << std::endl;
}
}