voidHVprojection(Matimage){//find the vertical projectionMatsmothedRes=image.clone();vectorv_vl_proj;//holds the column sum values
double max_vl_proj_h=0,max_vl_proj_v=0;//holds the maximum value
double average_v=0;for(int i=0;i
col=image.col(i);col_sum=sum(col);//find the sum of ith column
v_vl_proj.push_back(col_sum.val[0]);//push back to vectorif(col_sum.val[0]>max_vl_proj_v)max_vl_proj_v=col_sum.val[0];average_v+=col_sum.val[0];}average_v=average_v/image.cols;//find the horizontal projection
vectorh_vl_proj;//holds the row sum values
double average_h=0;for(int i=0;i
row=image.row(i);row_sum=sum(row);//find the sum of ith row
h_vl_proj.push_back(row_sum.val[0]);//push back to vectorif(row_sum.val[0]>max_vl_proj_h)max_vl_proj_h=row_sum.val[0];average_h+=row_sum.val[0];}average_h=average_h/image.rows;//******************Plottingvertical projection*******************for(int j=1;j
line(image,Point(0,average_y),Point(image.cols,average_y),Scalar(255,255,255),1,8);//***************Plottinghorizontal projection**************for(int j=1;j
v_vl_proj=smoothing(v_vl_proj);for(int j=1;j
line(smothedRes,Point(0,average_y1),Point(smothedRes.cols,average_y1),Scalar(0,255,0),1,8);imshow("SMoothed",smothedRes);imwrite("Vertical_projection.jpg",smothedRes);waitKey(0);}