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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:03:38+00:00 2026-06-05T08:03:38+00:00

I’m approaching a task of Bio Informatics, and need to extract some features from

  • 0

I’m approaching a task of Bio Informatics, and need to extract some features from some cell images.

I used SIFT algorithm to extract Key Points inside of the image, as you can see in the picture.

enter image description here

As you can also see in the picture (circled in red), some key points are outliers and I don’t want to calculate any feature on them.

I obtained the cv::KeyPoint vector with the following code:

const cv::Mat input = cv::imread("/tmp/image.jpg", 0); //Load as grayscale

cv::SiftFeatureDetector detector;
std::vector<cv::KeyPoint> keypoints;
detector.detect(input, keypoints);

but I would like to discard from the vector all those key points that, say for example, have less than 3 key points inside of a certain region of interest (ROI) centred on them in the image.

Therefore I need to implement a function returning the number of key points inside of a certain ROI given as input:

int function_returning_number_of_key_points_in_ROI( cv::KeyPoint, ROI );
   //I have not specified ROI on purpose...check question 3

I have three questions:

  1. Is there any existing function doing something similar?
  2. If not can you give me some help in understanding how to implement it by myself?
  3. Would you use a circular, or rectangular ROI for this task?And how would you specify it in input?

Note:

I forgot to specify that I would like an efficient implementation for the function, i.e. checking for each key point the relative position of all others with respect to it would not be a good solution (if there exists another way of doing).

  • 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-05T08:03:40+00:00Added an answer on June 5, 2026 at 8:03 am

    I decided to go with the statistical route, but this may not work if you have multiple cells in view.

    My solution is fairly straightforward:

    1. Compute the keypoint locations
    2. Find the centroid of the keypoint spatial locations
    3. Compute the Euclidean distance of all points to the centroid
    4. Filter original keypoints by distance < mu + 2*sigma

    Here is the image that I get using this algorithm (keypoints == green, centroid == red):

    enter image description here

    Finally, here is the code example of how I did it:

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/features2d/features2d.hpp>
    
    #include <iostream>
    #include <vector>
    
    using namespace cv;
    using namespace std;
    
    void distanceFromCentroid(const vector<Point2f>& points, Point2f centroid, vector<double>& distances)
    {
        vector<Point2f>::const_iterator point;
        for(point = points.begin(); point != points.end(); ++point)
        {
            double distance = std::sqrt((point->x - centroid.x)*(point->x - centroid.x) + (point->y - centroid.y)*(point->y - centroid.y));
            distances.push_back(distance);
        }
    }
    
    int main(int argc, char* argv[])
    {
        Mat input = imread("cell.jpg", 0); //Load as grayscale
    
        SiftFeatureDetector detector;
        vector<cv::KeyPoint> keypoints;
        detector.detect(input, keypoints);
    
        vector<Point2f> points;
        vector<KeyPoint>::iterator keypoint;
        for(keypoint = keypoints.begin(); keypoint != keypoints.end(); ++keypoint)
        {
            points.push_back(keypoint->pt);
        }
    
        Moments m = moments(points, true);
        Point2f centroid(m.m10 / m.m00, m.m01 / m.m00);
    
        vector<double> distances;
        distanceFromCentroid(points, centroid, distances);
    
        Scalar mu, sigma;
        meanStdDev(distances, mu, sigma);
    
        cout << mu.val[0] << ", " << sigma.val[0] << endl;
    
        vector<KeyPoint> filtered;
        vector<double>::iterator distance;
        for(size_t i = 0; i < distances.size(); ++i)
        {
            if(distances[i] < (mu.val[0] + 2.0*sigma.val[0]))
            {
                filtered.push_back(keypoints[i]);
            }
        }
    
        Mat out = input.clone();
        drawKeypoints(input, filtered, out, Scalar(0, 255, 0));
    
        circle(out, centroid, 7, Scalar(0, 0, 255), 1);
    
        imshow("kpts", out);
        waitKey();
    
        imwrite("statFilter.png", out);
    
        return 0;
    }
    

    Hope that helps!

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.