[Image] position, orientation and projection of binary images

Source: Internet
Author: User

A binary image is an image made up of 0, 1. We can get a series of information about images through some simple calculations.


Area:

Sum of all 1


Location:

The position of the image is generally expressed by centroid, and we can calculate the centroid of the x-axis and y-axis direction directly according to the definition of centroid, then get the center (XM,YM)



Orientation:

The definition of orientation given in the book "Machine Vision":

Here, we need to ask for the smallest second moment corresponding to the axis.

We use a point and the angle of the line and the x-axis to define the position of the axis, first we are deduced to obtain: the smallest second moment corresponding to the axis through the centroid.

Next, we only need an angle.

which


Projection:

In simple terms, the projection is the sum of 1 in one direction.


In concrete implementations, we can use incremental thinking to speed up operations. We know that when the image is loaded, we load the image one line at a time, so we can calculate the first and second moments in this process, and then calculate some of the eigenvalues of the binary image.

Matlab code:

function twovalueimg (f)
[m,n] = size (f);
s = 0;  % area
x1 = 0;% First order moment x direction
y1 = 0;% First order moment y direction
a = 0;% Second moment
b = 0; second moment
c = 0;% second moment for
i = 1:m
    for j = 1:n
        if (f (i,j) ==1)% increment thought
            s = s + 1;
            X1 = x1 + i;
            Y1 = y1 + j;
            A = a + I*i;
            B = b + i*j;
            c = C + j*j;
        End End End


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.