Define head function#ifndef ps_algorithm_h_included#define ps_algorithm_h_included#include <iostream># Include <string> #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# Include "ps_algorithm.h" #include <time.h>using namespace std;using namespace CV; #define PI 3.1415926int main () {s Tring Img_name ("4.jpg"); Mat Img; Img=imread (Img_name); float THETA=PI/6; int width=img.cols; int height=img.rows; /*//horizontal skewing int new_height=height; int New_width=width+height*tan (theta) +1; Mat Img_h=mat::zeros (New_height,new_width, CV_8UC3); float Dis; float new_x, new_y; Float x1, y1, p; for (int y=0; y<new_height; y++) {dis= (height-y) *tan (theta); for (int x=0; x<new_width; x + +) {new_y=y; Right skew//NEW_x=x-dis; Left skew New_x=x+dis-height*tan (theta); if (new_x<0) new_x=0; if (new_x>width-1) new_x=width-2; if (new_x>0 && new_x<width-1) {x1=int (new_x); Y1=int (new_y); p=new_x-x1; Img_h.at<vec3b> (y,x) [0]= (1-p) *img.at<vec3b> (y1,x1) [0]+p*img.at<vec3b> (y1,x1+1) [0]; Img_h.at<vec3b> (y,x) [1]= (1-p) *img.at<vec3b> (y1,x1) [1]+p*img.at<vec3b> (y1,x1+1) [1]; Img_h.at<vec3b> (y,x) [2]= (1-p) *img.at<vec3b> (y1,x1) [2]+p*img.at<vec3b> (y1,x1+1) [2]; }}} show_image (Img_h, "out"); Imwrite ("H.jpg", img_h); *///Vertical skewing int New_height=height+width*tan (theta) +1; int new_width=width; Mat Img_v=mat::zeros (New_height,new_width, CV_8UC3); float Dis; float new_x, new_y; Float x1, y1, p; for (int y=0; y<new_height; y++) { for (int x=0; x<new_width; x + +) {Dis=x*tan (theta); New_x=x; Right skew New_y=y-dis; Left skew//New_y=y+dis-width*tan (theta); if (new_y>0 && new_y
Original
Opencv--skewing