// define head function#ifndef PS_ALGORITHM_H_INCLUDED#define PS_ALGORITHM_H_INCLUDED#include #include #include "cv.h"#include "highgui.h"#include "cxmat.hpp"#include "cxcore.hpp"#include "math.h"using namespace std;using namespace cv;void Show_Image(Mat&, const string &);#endif // PS_ALGORITHM_H_INCLUDED/*This program will generate the garland.*/#include "PS_Algorithm.h"#include using namespace std;using namespace cv;#define pi 3.1415926int main(){ Mat Img(400,600, CV_32FC3); int width=Img.cols; int height=Img.rows; Point Center(width/2, height/2); int k=4; int N=720; float R=150.0; float dn; dn=360.0/N; float theta; float r; float x,y; float new_x, new_y; for (int i=0; i<=N; i++) { theta=(i*dn)*pi/180.0; r=R*sin(k*theta); x=(r*cos(theta)); y=(r*sin(theta)); new_y=(int)(Center.y-y); new_x=(int)(Center.x+x); Img.at (new_y, new_x)[0]=1; Img.at (new_y, new_x)[1]=1; Img.at (new_y, new_x)[2]=1; } Show_Image(Img, "out"); imwrite("Out.jpg", Img*255); waitKey();}// define the show image#include "PS_Algorithm.h"#include #include using namespace std;using namespace cv;void Show_Image(Mat& Image, const string& str){ namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE); imshow(str.c_str(), Image);}