---------------------------------------------------------------------------------------------------------------
Description::
This is a C++ program to show the use of transpose funtion which is inbuilt in the opencv library. Transpose function takes 2 parametres. FIrst is mat object for input image and second is mat object of another desired output transposed image. Transpose image is used to transpose the given input image as shown in the output in the below part.
---------------------------------------------------------------------------------------------------------------
Program::
#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
char* ImageFile = argv[1]; //image file
Mat image;
image = imread( imageName, IMREAD_COLOR ); //reading file
if( argc != 2 || !image.data )
{
printf( " No image data \n " );
return -1;
}
Mat transposed_image; //Mat object for storing data
transpose(image,transposed_image); //transposing given input image
imwrite( "/home/crmgogo/Pictures/transposed_image.jpg", transposed_image ); //Saving images
namedWindow( imageName, WINDOW_NORMAL );
namedWindow( "transposed_image", WINDOW_NORMAL );
imshow( imageName, image ); //show windows
imshow( "transposed_image", transposed_image );
waitKey(0);
return 0;
}
---------------------------------------------------------------------------------------------------------------
Commands to run program on terminal::
$ g++ -ggdb `pkg-config --cflags filename` -o `basename filename .cpp` filename `pkg-config --libs opencv`
$ ./cvopen filename
---------------------------------------------------------------------------------------------------------------
Output::
Comments