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 9200537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:47:26+00:00 2026-06-17T22:47:26+00:00

Basically I am trying to convert the below output image to color(RGB). The image

  • 0

Basically I am trying to convert the below output image to color(RGB). The image that this code currently outputs is grayscale, however, for my application I would like it to be output as color. Please let me know where I should convert the image.

Also the code below is C++ and it using a function from openCV. Please keep in mind that I am using a wrapper to use this code in my iphone application.

cv::Mat CVCircles::detectedCirclesInImage(cv::Mat img, double dp, double minDist, double    param1, double param2, int min_radius, int max_radius) {
//(cv::Mat img, double minDist, int min_radius, int max_radius)


if(img.empty())
    {
    cout << "can not open image " << endl;
    return img;
    }
Mat cimg;
medianBlur(img, img, 5);

cvtColor(img, cimg, CV_GRAY2RGB);

vector<Vec3f> circles;
HoughCircles(  img      //InputArray 
             , circles  //OutputArray
             , CV_HOUGH_GRADIENT  //int method
             , 1//dp              //double       dp=1   1 ... 20
             , minDist         //double minDist=10 log 1...1000
             , 100//param1          //double  param1=100
             , 30//param2          //double  param2=30  10 ... 50
             , min_radius      //int  minRadius=1   1 ... 500
             , max_radius      //int  maxRadius=30  1 ... 500
             );

for( size_t i = 0; i < circles.size(); i++ )
    {
    Vec3i c = circles[i];
    circle( cimg, Point(c[0], c[1]), c[2], Scalar(255,0,0), 3, CV_AA);
    circle( cimg, Point(c[0], c[1]), 2, Scalar(0,255,0), 3, CV_AA);
    }


return cimg;
}
  • 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-06-17T22:47:28+00:00Added an answer on June 17, 2026 at 10:47 pm

    This is currently set up to expect a grayscale image as input. I think that you are asking how to adapt it to accept a colour input image and return a colour output image. You don’t need to change much:

    cv::Mat CVCircles::detectedCirclesInImage(cv::Mat img, double dp, double minDist, double  param1, double param2, int min_radius, int max_radius) {
    
      if(img.empty())
            {
            cout << "can not open image " << endl;
            return img;
            }
      Mat img;
    
      if (img.type()==CV_8UC1) {
                  //input image is grayscale
        cvtColor(img, cimg, CV_GRAY2RGB);
    
      } else {
                  //input image is colour
        cimg = img;
        cvtColor(img, img, CV_RGB2GRAY);
      }
    

    the rest stays as is.

    If your input image is colour, you are converting it to gray for processing by HoughCircles, and applying the found circles to the original colour image for output.

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

Sidebar

Related Questions

I have a fairly lengthly block of code that I'm trying to convert from
I am basically trying to convert a solution to this question into a rake
I am basically trying to convert a string similar to this one: 2011-11-9 18:24:12.3
I'm trying to convert some strings that are in French Canadian and basically, I'd
I'm basically trying to convert a Unix timestamp (the time() function) to a relative
Basically on .show() I've been trying to have all of the inputs convert to
I am trying to convert a uncommon date format into a standard date. Basically
I'm trying to convert this ASP.net(vb) script to pure Javascript and I'm running into
Hi everyone im currently busy trying to convert a duplicatable form to an jsonstring,
So basically I'm trying to convert characters from ISO-8859-2 to windows-1250. Unfortunately none of

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.