Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:08:46+00:00 2026-05-25T17:08:46+00:00

I am trying to pass in a HSV frame from a video to the

  • 0

I am trying to pass in a HSV frame from a video to the function, but the function does not seem to do anything to it. What am I doing wrong? The function is supposed to go through each pixel, and depending on its hue range supposed to make it black or white, leaving me with a binary image. Instead it doesn’t seem to affect the HSV image at all….

Thanks
PS sorry for the bad code formatting, StackOverflow isn’t allowing me to post the original format.

void sort (IplImage *skinmask)
{
  for (int row=0; row<=skinmask->height;row++)
  {
    uchar* pixelrow=(uchar*)(skinmask->imageData+(row*(skinmask->widthStep)));
    for (int column=0; column<=skinmask->width; column++)
    {
        if (6<pixelrow[3*column]<36)
        {
            pixelrow[3*column]=256;
            pixelrow[(3*column)+1]=256;
            pixelrow[(3*column)+2]=256;
        }
        else
        {
            pixelrow[3*column]=0;
            pixelrow[(3*column)+1]=0;
            pixelrow[(3*column)+2]=0;
        }
        column++;
    }
    row++;
  }
  cvMorphologyEx(skinmask,skinmask,NULL,NULL,CV_MOP_CLOSE,1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:08:47+00:00Added an answer on May 25, 2026 at 5:08 pm

    Doing an operation like thresholding pixel-by-pixel is usually the wrong way to go about achieving this in OpenCV – there are functions that work on whole image arrays that are simpler and are already optimized for speed.

    In this case try first splitting the image to separate out the H/S/V channels, then threshold on the Hue channel to get a mask (you may have to use the intersection of two masks, which you can do using a multiply or "bitwise and") – the resulting mask is your black and white image.

    (I realise I’ve linked to the C++ documentation, but I’m sure you can find the equivalent functions in the old-style OpenCV docs)

    Update

    Ok, I’ll try to write some code to show what I mean. I also found the function I was looking for, which is better than Threshold, it is InRangeS. This lets you put upper and lower bounds on all the channels at once, and it applies them all into your mask for you.

    void HSVImageToMask(IplImage * image, cvMat * mask)
    /* mask should be the same size as image, and of type CV_8UC1            */
    /* e.g. cvMat * mask = cvCreateMat(image->width, image->height, CV8UC1); */
    {
      double hMin = 6;
      double hMax = 36;
      double sMin = 10;  /* not sure what value you need */
      double sMax = 245; /* not sure what value you need */
      double vMin = 0;
      double vMax = 255;
    
      CvScalar hsvMin = cvScalar(hMin, sMin, vMin);
      CvScalar hsvMax = cvScalar(hMax, sMax, vMax);
    
      cvInRangeS(image, hsvMin, hsvMax, mask);
    }
    

    PS. I figured out the problem with your original code – you should be using 255 instead of 256 as your "white" value. This method is still better though 🙂

    PPS. We didn’t need them after all but for future reference:

    "bitwise and":

    cvAnd(const CvArr* src1, const CvArr* src2, CvArr* dst)
    

    If you have two black and white masks, this will give you the intersection. Use cvOr to get the Union.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to pass an array of values from PHP function to Javascript. Not
Iam trying to pass dynamic argument values i.e username from request using spring ioc.But
I am trying to pass not only the dropdownlist ID using this, but I'm
Trying to pass the values but not making progress. Scenario : Have a public
Am trying to pass a argument in jquery html pop up.But am not able
Trying pass the recheck of ARC conversion, but I am not sure how to
I am trying to pass a folder path from XSL to JavaScript. Function is
I'm trying to pass a variable from the URL (not the query string) to
Trying to pass a closure into filter_var_array(), but can't seem to make it work.
Trying to pass something to something else. Says undefined. Not sure how or why.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.