MATLAB draw dot calibration plate

foreword

This article mainly uses the rectangle function in Matlab to draw the dot calibration board. It mainly describes how to understand and design the size and quantity of the dots, and how to establish the origin coordinate system of the calibration board so that the center of the calibration board is on the origin.

text

Create dot parameters

How to use MATLAB to draw a solid circle? The function used here isrectangle()
On MATLAB, the syntax for the retangle() function is as follows.

rectangle(‘Position’,pos)
rectangle(‘Position’,pos,‘Curvature’,cur)
rectangle(___,Name,Value)
rectangle(ax,___)
r = rectangle(___)
可通过help rectangleordoc rectangleto get a detailed description of the rectangle.

In this article, the main syntax used is rectangle('Position',pos,'Curvature',cur)

A detailed explanation of the function

% pos = [x y w h],它是一个四维的,一行四列的行向量 
% x、y元素表示的是该圆的平面位置
% w、h元素表示的是该圆的宽度和高度

Notice! ! !
In the rectangle function, the [x,y] element in pos expresses that the origin is the lower left corner of the rectangle, not the plane center of the rectangle.

% cur = [horizontal vertical]
% cur为双精度类型的标量,范围[0 1]内的双精度类型的1x2矢量
% 由于我们建立的是圆点标定板,因此cur=[1,1],若方形则为[0,0]

Explanation of Curvature
How to explain curvature concisely? .

Since what we want to draw is a black dot calibration board, we need to format the circle after this function, that is, the edge coloredgecolorand surface colorfacecolor

Therefore, the main body of the dot calibration plate is determined.MATLABThe code structure is as follows:

rectangle('Position',D{i,j},'Curvature',[1,1],...
 		  'edgecolor',[0,0,0],'facecolor',[0,0,0])
%其中[0,0,0]代表RGB为0,0,0的黑色
%需要什么颜色直接去查该颜色的RGB
%边缘颜色和表面颜色都设为RGB为0,0,0的黑色,因此该圆为黑色的实心圆

Next explainD{i,j}, first give the code sliceD{i,j} = [X Y d/2 d/2];
X 表示圆的x轴坐标
Y 表示圆的y轴坐标
由于我们画的是圆,因此该圆的宽度和高度都为半径,即d/2

Create a coordinate system

The establishment of the dot calibration version mainly completes the following three points

  1. Create a dot calibration plate of dotssize: Set the diameter of the dot to be 2.5mm .
  2. Set the dots of each dot on the dot calibration platespacing: Set the spacing to 5mm .
  3. Create a dot calibration plate of dotsquantity: There are 11 rows and 11 columns of dots , a total of 121 dots.
  4. Create a dot calibration plateorigin coordinates: Set the exact center of the dot calibration plate as the coordinate origin.

The distribution and parameters of each point on the calibration plate are given below
Distribution and parameters of the calibration plate
Let the diameter be d, the row and column be n, and the gap be s, then
d = 2.5;
n = 21;
s = 5

Let the x-coordinate of the initial circle be x 0 and the y-coordinate be y 0 , first set x 0 and y 0 to 0, then:
x0 = 0;
y0 = 0;

Since there is a gap of 5 mm between the dots , in order to intuitively see how each coordinate system is divided into steps, the coordinates of each dot distributed are given as:

for i = 1:n
    x(i) = x0 + s*(i-1);
    y(i) = y0 + s*(i-1);
end

The [x(i), y(i)] coordinates represent the coordinates of each dot

Let's start drawing the calibration board

figure(1)
for i = 1:n
    X = x(i);
    for j = 1:n
        Y = y(j);
        D{
    
    i,j} = [X Y d/2 d/2];
        % 使用rectangle来画实心圆
        rectangle('Position',D{
    
    i,j},'Curvature',[1,1],...
          		  'edgecolor',[0,0,0],'facecolor',[0,0,0])
        hold on
    end
end

The effect presentedas follows:
Image with starting coordinates [0,0]
Due to the need toThe center of the calibration plate is set as the coordinate origin, so it needs to be translated for a certain distance. After calculation, the starting coordinate is set as
x0 = -(n-1)*d-d/4;
y0 = -(n-1)*d-d/4;

The effect presentedas follows
Image with center point coordinates [0,0]

code show as below:

clear
clc
close all
warning off
% 画圆点标定板,以标定板中心为原点
d = 2.5;
n = 21;
s = 5;
x0 = -(n-1)*d-d/4;%
y0 = -(n-1)*d-d/4;%
for i = 1:n
    x(i) = x0 + s*(i-1);
    y(i) = y0 + s*(i-1);
end
figure(1)
for i = 1:n
    X = x(i);
    for j = 1:n
        Y = y(j);
        D{
    
    i,j} = [X Y d/2 d/2];
        % 使用rectangle来画实心圆
        rectangle('Position',D{
    
    i,j},'Curvature',[1,1],...
          'edgecolor',[0,0,0],'facecolor',[0,0,0])
        hold on
    end
end
    
grid on %加网格
xlabel('x轴')
ylabel('y轴')
axis equal

Provide the compressed package link: draw dot calibration board .


References

MATLAB rectangle function .

Use the rectangle function in Matlab .

Guess you like

Origin blog.csdn.net/AlbertDS/article/details/122370054