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

  • Home
  • SEARCH
  • 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 6537747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:39:14+00:00 2026-05-25T10:39:14+00:00

So I have a 2-dimensional array representing a coordinate plane, an image. On that

  • 0

So I have a 2-dimensional array representing a coordinate plane, an image. On that image, I am looking for “red” pixels and finding (hopefully) the location of a red LED target based on all of the red pixels found by my camera. Currently, I’m simply slapping my crosshairs onto the centroid of all of the red pixels:

// pseudo-code

for(cycle_through_pixels)
{
   if( is_red(pixel[x][y]) )
   {
      vals++; // total number of red pixels
      cx+=x;  // sum the x's
      cy+=y;  // sum the y's
   }
}
cx/=vals; // divide by total to get average x
cy/=vals; // divide by total to get average y

draw_crosshairs_at(pixel[cx][cy]); // found the centroid

The problem with this method is that while this algorithm naturally places the centroid closer to the largest blob (the area with the most red pixels), I am still seeing my crosshairs jump off the target when a bit of red flickers off to the side due to glare or other minor interferences.

My question is this:

How do I change this pattern to look for a more weighted centroid? Put simply, I want to make the larger blobs of red much more important than the smaller ones, possibly even ignoring far-out small blobs altogether.

  • 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-25T10:39:14+00:00Added an answer on May 25, 2026 at 10:39 am

    You could find the connected components in the image and only include those components that have a total size above a certain threshold in your centroid calcuation.

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

Sidebar

Related Questions

I have a two dimensional array that I need to load data into. I
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
I have an 2 dimensional array that is full of 1s and 0s such
I have a multi-dimensional array similar to the example below that I want to
I have a multi-dimensional array that I am trying to feed into difflib.get_close_matches() .
I have a 2 dimensional array which is like that; $results[$i][$j]->title; $results[$i][$j]->snippet; $results[$i][$j]->link; It
I have three dimensional array of data that is generated from web server logs
I have a 2 dimensional array, like so: char[,] str = new char[2,50]; Now,
I have a 2-dimensional array of objects and I basically want to databind each

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.