Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Any easier way to do this?

I want to compare my labeled image to a vector of background labels.if they matches change that label to 255.Here is my code:

void markBackground(Mat input,vector backgroundLabel)
     for(int x=0;x<input.cols;x++)
        for(int y=0;y<input.rows;y++)
            for(int i=0;i<backgroundLabel.size();i++){
                if(input.at<uchar>(y,x)==backgroundLabel[i])input.at<int>(y,x)=255;            
        }

It involes 3 loops not very neat any other way to do this?