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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:50:55+00:00 2026-06-14T13:50:55+00:00

Using Matlab’s image processing toolbox I can find weighted centroids using the regionprops function

  • 0

Using Matlab’s image processing toolbox I can find weighted centroids using the regionprops function. This is because the function can return either a WeightedCentroid or a list of pixels indices per labeled part of the image, by PixelList, and then the weighted centroid is easily calculated. However, jacket’s support in regionprops only returns an unweighted centroid (or the centroid of the binary “island” that was obtained using bwlabel earlier). This means that the info regarding pixel positions was somehow used in order to find these centroids.

How can I access jacket’s regionprops info regarding the list of pixels it uses to calculate the unweighted centroid so I could use it to calculate a weighted centroid?
(One important reason to do this is because the function find cannot be used in a gfor loop, otherwise one can find the different output values of bwlabel…)

  • 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-14T13:50:56+00:00Added an answer on June 14, 2026 at 1:50 pm

    I have not tested performance, but here is an algorithm to get weighted centroids and areas.
    This should work with Jacket as well as matlab (depending on the type of Input).

    function [WC, WA] = WeightedMoments(L, I);
      [m, n] = size(L);
      [keys, idx] = sort(L(:));
    
      % Get weights and locations in sorted order
      w = I(idx);
      idx = idx - 1; % Convert to 0-index for simplicity
      x = floor(idx / m);
      y = idx - x * m;
    
      % Location of the starting point of each region.
      locs = find([diff(keys); 1]);
    
      % Weighted area and locations
      Msum = cumsum([w, x.*w, y.*w]);
      Mloc = diff(Msum(locs,:));
      M00 = Mloc(:, 1);
      M10 = Mloc(:, 2);
      M01 = Mloc(:, 3);
    
      % Weighted centroids and areas
      WC = [M10 ./ M00, M01 ./ M00] + 1; % Convert back to 1-index
      WA = M00;
    end
    

    P.S. I am a developer at AccelerEyes. Sorry about the delay.

    EDIT: Cleaned up the code a little bit.

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

Sidebar

Related Questions

I am creating an Excel using the Matlab xlswrite function. How can I change
I am using Matlab Symbolic Toolbox with its solve function and attempting to solve
how can I extract filiform areas on the center of an image using MATLAB
Using Matlab, I have to transform the intensity of an image using this given
I am using Matlab and am using its solve function. I run this code
How can I generate a set of image projections using MATLAB ? I have
How can I write an image including EXIF data? I am using Matlab and
Using MATLAB, I have this code: value = input('>> Enter a value: '); and
I am using matlab's randn function to generate random random numbers from a standard
I'm using Matlab to find effective ways of deconvolving the output of a spectrometer

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.