Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong background in use cvFilterLabels #11

Closed
GoogleCodeExporter opened this issue Sep 25, 2015 · 1 comment
Closed

Wrong background in use cvFilterLabels #11

GoogleCodeExporter opened this issue Sep 25, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. use function cvFilterLabels
2.
3.

What is the expected output? What do you see instead?
We want a black background. We see some pixel with wrong value (because this 
pixel are not check).

What version of the product are you using? On what operating system?
version 0.10.1. Windows 7, 64 bits

Please provide any additional information below.
My correction:

  void cvFilterLabels(IplImage *imgIn, IplImage *imgOut, const CvBlobs &blobs)
  {
    CV_FUNCNAME("cvFilterLabels");
    __CV_BEGIN__;
    {
      CV_ASSERT(imgIn&&(imgIn->depth==IPL_DEPTH_LABEL)&&(imgIn->nChannels==1));
      CV_ASSERT(imgOut&&(imgOut->depth==IPL_DEPTH_8U)&&(imgOut->nChannels==1));

      int stepIn  =  imgIn->widthStep / ( imgIn->depth / 8);
      int stepOut = imgOut->widthStep / (imgOut->depth / 8);
      int imgIn_width  = imgIn->width;
      int imgIn_height = imgIn->height;
      int imgIn_offset = 0;
      int imgOut_width  = imgOut->width;
      int imgOut_height = imgOut->height;
      int imgOut_offset = 0;
      if(imgIn->roi)
      {
    imgIn_width  = imgIn->roi->width;
    imgIn_height = imgIn->roi->height;
    imgIn_offset = imgIn->roi->xOffset + (imgIn->roi->yOffset * stepIn);
      }
      if(imgOut->roi)
      {
    imgOut_width = imgOut->roi->width;
    imgOut_height = imgOut->roi->height;
    imgOut_offset = imgOut->roi->xOffset + (imgOut->roi->yOffset * stepOut);
      }

      char *imgDataOut=imgOut->imageData + imgOut_offset;
      CvLabel *imgDataIn=(CvLabel *)imgIn->imageData + imgIn_offset;

      for (unsigned int r=0;r<(unsigned int)imgIn_height;r++,
      imgDataIn+=stepIn,imgDataOut+=stepOut)
      {
        for (unsigned int c=0;c<(unsigned int)imgIn_width;c++)
        {
          if (imgDataIn[c])
          {
            if (blobs.find(imgDataIn[c])==blobs.end()) imgDataOut[c]=0x00;
            else imgDataOut[c]=(char)0xff;
          }
          else
              imgDataOut[c]=(char)0x00; //add by me to correct bug
        }
      }
    }
    __CV_END__;
  }


Original issue reported on code.google.com by mathias....@gmail.com on 30 Jun 2010 at 1:04

@GoogleCodeExporter
Copy link
Author

I've just submit the fix to the repository.

Anyway, perhaps I include a function that does not write 0x00 in any case, in 
order to print blobs in another binary image.

Thank you very much!

Original comment by grendel....@gmail.com on 1 Jul 2010 at 9:12

  • Changed state: Fixed
  • Added labels: Usability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant