% 初始化设定
close all
% 设置图片大小
pix_x = 190; %图片宽度像素数
pix_y = 190; %图片高度像素数
margin_h = 0.1; %水平方向上留10%空余
margin_v = 0.1; %垂直方向上留10%空余
lamda1 = 0.2; %短边凸的程度(0~0.5)
lamda2 = 0.4; %长边凹的程度(0~0.5)
% 边距象素值
v = margin_v*pix_y;
h = margin_h*pix_x;
% 在矩阵的上半部分随机地取2点
point1_y = round(v+rand*(pix_y/2-v)); %矩阵行坐标
point1_x = round(h+rand*(pix_x-2*h)); %矩阵列坐标
point2_y = round(v+rand*(pix_y/2-v));
point2_x = round(h+rand*(pix_x-2*h));
% 4个点的矩阵坐标
P1 = [point1_y; point1_x];
P2 = [point2_y; point2_x];
% 中心对称
P3 = [pix_y; pix_x] - P1;
P4 = [pix_y; pix_x] - P2;
% 规定短边凸出,长边凹入
if sum((P1-P2).^2) > sum((P1-P4).^2)
temp = lamda1;
lamda1 = lam