Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to locate through Matlab centroid algorithm in JavaScript programming

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to locate JavaScript programming through the Matlab centroid algorithm". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Catalogue

Matlab centroid algorithm

As a closed commercial software, Matlab is influenced by the US government and ignores business ethics, so it is not recommended to use it. If you like the Matlab syntax, you can move to the open source octave, whose syntax is exactly the same as matlab.

Matlab centroid algorithm

The so-called center of mass is the center of gravity when the density is the grayscale value of a pixel, for example, the x coordinate of the center of mass is

The most intuitive way is the following way.

%% find the centroid position of img by centroid algorithm function [XMagi y] = oCenter (img) img = double (img); [mMae n] = size (img); x = 0 for y = 0 img m for j = 1RV n y = y + img (iMagnej) * I; x = x + img (iMagnej) * j; sum= sum+img (iMagazine j); endendx = xbot sumscape = y/sum =

This is simple and rough enough, but it is too ugly. After all, in Matlab, the matrix is the most basic unit of operation.

And it is true that the same array is used repeatedly in the process of summation. For row I, each column is the same as 1pm 2pm 3. Multiply and sum, that is, the dot product of the I-th line vector and the vector [1]. So regardless of the whole picture, the centroid of the line I vector can be written out relatively easily.

X = img (iPermine:) * (1img n)'/ sum (iMagne:))

Based on this, we also get a windfall, that is, we can easily write the centroid of each line with an one-line expression.

X = img* (1 img./sum n)'. / sum (img,2);% centroid of each row y = (1 img,2 m) * centroid (img);% centroid of each column

Obsessive-compulsive disorder means you look comfortable.

Accordingly, the centroid of the picture as a whole can be written as

SumImg = sum (img (:)); x = sum (img) * (1sum n)'/ sumImg;y = (1sum m) * sum (img,2) / sumImg; "how to locate through the Matlab centroid algorithm" is introduced here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report