How to make the fuctions call in main by connecting other functions each othr :example please [closed]

asked 2015-06-05 00:33:24 -0600

sandun gravatar image

//http://www.learncpp.com/cpp-tutorial/78-function-pointers/ //http://www.codeguru.com/cpp/cpp/article.php/c17401/C-Tutorial-PointertoMember-Function.htm #include <opencv2 core="" core.hpp=""> #include <opencv2 highgui="" highgui.hpp=""> #include <iostream> #include <opencv2 imgproc="" imgproc.hpp=""> #include <stdio.h> #include <stdlib.h> using namespace cv; using namespace std; //Global variables Mat src_my_rgb, erosion_dst, dilation_dst,smoothed_dst;//src_my_rgb is the rgb source file for dialation/irosion.

int erosion_elem = 0; int erosion_size = 1; int dilation_elem = 0;//dilation for filling holes. int dilation_size = 0.5; int const max_elem = 2; int const max_kernel_size = 21;

//* Function Headers void Erosion( int, void* ); void Dilation( int, void* ); void t_b_invertd(int,void); //function main

int main( ) { void Dilation( int, void* ); void Erosion( int, void* );

   Mat image;

// LOAD image image = imread("C:\Users\A\Desktop\project support\dummy my source\mypic.jpg",CV_LOAD_IMAGE_COLOR); // Read the file "image.jpg". // This file "image.jpg" should be in the project folder. //Else provide full address : "D:/images/image.jpg"

   if(! image.data )  // Check for invalid input
   {
          cout <<  "Could not open or find the image" << std::endl ;
          return -1;
   }

  // DISPLAY image
   namedWindow( "window", CV_WINDOW_AUTOSIZE ); // Create a window for display.
   imshow( "window", image ); // Show our image inside it.

  //SAVE image
   imwrite("result.jpg",image);// it will store the image in name "result.jpg"

//* // Create windows for erosion and dilation

moveWindow( "Dilation Demo", src_my_rgb.cols, 0 );

//LOAD image src_my_rgb = imread("C:\Users\A\Desktop\project support\dummy my source\mypic.jpg",CV_LOAD_IMAGE_COLOR);

//** Mat gray_image; cvtColor( image, gray_image, CV_BGR2GRAY );//http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#(0 is between 0to 255)

imwrite( "Gray_Image.jpg", gray_image );

//namedWindow( "imageName", CV_WINDOW_AUTOSIZE ); //namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );

imshow( "Gray image", gray_image ); //* //Smoothing by averaging //http://www.bogotobogo.com/OpenCV/opencv_3_tutorial_imgproc_gausian_median_blur_bilateral_filter_image_smoothing.php for(int i=1; i<4; i=i+1){ //smooth image in the"src" and save it in "dst" blur(gray_image,smoothed_dst,Size(i,i));//kernel size=3,3 //show the blurred image with the text namedWindow( "Smoothing by avaraging", CV_WINDOW_AUTOSIZE); imshow( "Smoothing by avaraging", smoothed_dst ); }

//* Mat src1; src1 = imread("mypic.jpg", CV_LOAD_IMAGE_COLOR); namedWindow( "Original image", CV_WINDOW_AUTOSIZE ); //imshow( "Original image", src1 );

Mat gray, edge, draw;
//cvtColor(src1, gray, CV_BGR2GRAY);//replaced by following

if(src1.empty()){ printf("The command line arguments are wrong.I am exiting.\n"); return 1;} //exit program with status 1 to indicate a non normal exit else if(src1.channels()>1) cvtColor(src1, gray, CV_BGR2GRAY); else gray = src1; Canny( smoothed_dst, edge, 50, 300, 3);//blurred image eka src lesa gena atha.

edge.convertTo(draw, CV_8U);
namedWindow("Canny image", CV_WINDOW_AUTOSIZE);
imshow("Canny image", edge);

//* // Create windows

namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE ); cvMoveWindow( "Dilation Demo", src_my_rgb.cols, 0 );

// Default start Dilation( 0,0 ); Erosion( 0,0 ); t_b_invertd(0,0);

   waitKey(0);                       // Wait for a keystroke in the window
   return 0;

}

/* * @function Dilation */ void Dilation( int, void ) { int dilation_type ; if( dilation_elem == 0 ){ dilation_type = MORPH_RECT; } else if( dilation_elem == 1 ){ dilation_type = MORPH_CROSS; } else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }

Mat element = getStructuringElement( dilation_type, Size( 2dilation_size + 1, 2dilation_size+1 ), Point( dilation_size, dilation_size ) ); /// Apply the dilation operation dilate( src_my_rgb, dilation_dst, element ); namedWindow( "Dilation Demo", WINDOW_AUTOSIZE ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2015-06-05 02:04:47.842024

Comments

This doesn't seem ROS related (although OpenCV is used). Please update your question if you think it is. Closing for now.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-05 02:05:25 -0600 )edit