Code Monkey home page Code Monkey logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 5, 2024
I've implemented cvRelabel and it works well for me:

void cvRelabel(CvBlobs blobs, IplImage* imgLabel) {
    int i=1;
    int stepLbl = imgLabel->widthStep/(imgLabel->depth/8);
    for (CvBlobs::const_iterator it=blobs.begin(); it!=blobs.end(); ++it, i++) {
        CvBlob* blob = it->second;
        if(blob->label != i) {            
            for(int y=0; y<imgLabel->height; y++ ) {
                CvLabel *label = (CvLabel *) imgLabel->imageData + y * stepLbl;
                for(int x=0; x<imgLabel->width; x++) {
                    if(*label == blob->label) {
                        *label = i;  
                    }
                    label++;
                }
            }
            blob->label = i;
        }
    }
}

Original comment by [email protected] on 12 Jan 2011 at 11:11

from cvblob.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 5, 2024
Hi Pablo,

CvBlobs is not a `vector` but a `map`. This way the "indexes" don't change when 
you filter blobs. I used maps for that reason. For example, you have:

  blobs[0], blobs[1], blobs[2], blobs[3]

After filter you could have:

  blobs[1], blobs[3]

Of course, if you use iterators you'll see that the "first" blobs has 
`label=1`, and next blob has `label=3`, but their indexes are the same. If you 
need to know the "index" of a iterator you can use `it->first`, but it should 
be the equal to `it->second->label`.

So, do a relabel or something like that seems unnecessary to me :-S Can you 
overcome the problem in any other way?

I could refactor all the library and use only vector instead of maps (vector 
must be more efficient), but I find maps easier when you program.

Regards,

Cristóbal

Original comment by [email protected] on 13 Jan 2011 at 9:57

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from cvblob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.