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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:14:15+00:00 2026-06-04T02:14:15+00:00

I have previously asked a question Marking an interest point in an image using

  • 0

I have previously asked a question Marking an interest point in an image using c++. I used the same solution and got the required point using the adaptive threshold and Blob Detection Algorithm(Growing Regions). I have the original source figure where I want to detect the rectangular region at the center

Original Image:

Original Image.But after I used the algorithm, I got something like this(details are visible if you open it in a new tab)

Marked Image:

enter image description here where apart from the rectangular region the bright day light illuminated spots are also visible. I have used bilateral filtering but still I am not able to detect the rectangular region.But this algorithm works for the Night image where the background is more darker as expected.

Can someone suggest me whether the same algorithm with some modifications is sufficient or any other efficient ways are available..

Thanks

  • 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-04T02:14:17+00:00Added an answer on June 4, 2026 at 2:14 am

    Using a simple combination of blur & threshold I managed to get this result (resized for viewing purposes):

    After that, applying erosion & the squares.cpp technique (which is a sample from OpenCV) outputs:

    which is almost the result you are looking for: the bottom part of the rectangle was successfully detected. All you need to do is increase the height of the detected rectangle (red square) to fit your area of interest.

    Code:

    Mat img = imread(argv[1]);
    
        // Blur
    Mat new_img = img.clone();
    medianBlur(new_img, new_img, 5);
    
    // Perform threshold
    double thres = 210;
    double color = 255;
    threshold(new_img, new_img, thres, color, CV_THRESH_BINARY);
    imwrite("thres.png", new_img);
    
    // Execute erosion to improve the detection
    int erosion_size = 4;   
    Mat element = getStructuringElement(MORPH_CROSS,
                                       Size(2 * erosion_size + 1, 2 * erosion_size + 1),
                                       Point(erosion_size, erosion_size) );
    erode(new_img, new_img, element);
    imwrite("erode.png", new_img);
    
    vector<vector<Point> > squares;
    find_squares(new_img, squares);
    std::cout << "squares: " << squares.size() << std::endl;
    
    draw_squares(img, squares);
    
    imwrite("area.png", img);
    

    EDIT:

    The find_squares() function returns a vector with all the squares found in the image. Because it iterates on every channel of the image, on your example it successfully detects the rectangular region in each of them, so printing squares.size() outputs 3.

    As a square can be seen as a vector of 4 (X,Y) coordinates, OpenCV express this concept as vector<Point> allowing you to access the X and Y part the coordinate.

    Now, printing squares revelead that the points were detected in a counterclockwise direction:

    1st ------ 4th
     |          |
     |          |
     |          |
    2nd ------ 3rd
    

    Following this example, its fairly obvious that if you need to increase the height of the rectangle you need to change the Y of the 1st and 4th points:

    for (int i = 0; i < squares.size(); i++)
    {
        for (int j = 0; j < squares[i].size(); j++)
        {
        //  std::cout << "# " << i << " " << squares[i][j].x << ","<< squares[i][j].y << std::endl;
            if (j == 0 || j == 3)
                squares[i][j].y = 0;
        }
    }
    

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

Sidebar

Related Questions

I have previously asked a question on AS3 and timing for games but got
I have previously asked a question to populate a page depending on which link
I have previously asked a question on how to echo the url of images
This problem is similar to my previously asked question. When I query data using
I have previously asked a question about how can I write a code block
I've previously asked a question of about Delegates does anyone have a must have
I previously asked this question about how to make versioned serializaion using boost::serialization::access I
I previously asked this question here: Stop user from using enter to pass a
I previously asked the question How to zoom subplots together? , and have been
I've previously asked a question about an issue I have been experiencing with CSharpOptParse

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.