#include<opencv2/opencv.hpp>
#include<iostream>
#include<ctime>
#include<cmath>
#define PI 3.14159265358979 / 180
#define PI_ 3.14159265358979
using namespace std;
using namespace cv;
Mat img(Size(1000, 1000), CV_8UC3, Scalar(0, 0, 0));
void cantor(Point p1, Point p2);
void Koch(Point p1, Point p2, int c);
void Ramus(Point p, double alpha, double L, int n);
void tree(int x, int y, double L, double alpha);
int main()
{
Point p1(0,500);
Point p2(500, 500);
Point p(500, 1000);
//cantor(p1, p2);
//Koch(p1, p2, 100);
//Ramus(p, 45, 250, 16);
tree(p.x, p.y, 240, 270);
imshow("图片", img);
imwrite(to_string(clock())+".png", img);
waitKey();
return 0;
}
void cantor(Point p1, Point p2) {
Point p3, p4;
int d = 30;
if ((p2.x - p1.x) <1) {
line(img, p1, p2, Scalar(255, 255, 255), 1, 8, 0);
}
else {
line(img, p1, p2, Scalar(255, 255, 255), 1, 8, 0);
p3.x = p1.x + (p2.x
opencv实现分形树
最新推荐文章于 2022-06-20 14:29:16 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)