---------------------------------------------------------------------------------------------------------------
Description::
The pow function raises every array element to a power. For an integer array the power is calculated normally.For a non-integer power exponent, the absolute values of input array elements are used. It is possible to get true values for negative values using some extra operations.For non-integer p, the absolute value of the source value is computed first, and then raised to the power p (so only real values are returned). For some special values of p, such as integer values special algorithms are used, resulting in faster computation.
---------------------------------------------------------------------------------------------------------------
Program::
#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
char* imageName = 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 neg_image,pos_image; //Mat object for storing data pow(image,-10, neg_image); //pow function
pow(image,10, pos_image);
imwrite( "/home/crmgogo/Pictures/neg_Image.jpg", neg_image ); //saving image
imwrite( "/home/crmgogo/Pictures/pos_Image.jpg", pos_image );
namedWindow( imageName, WINDOW_NORMAL );
namedWindow( "neg image", WINDOW_NORMAL );
namedWindow( "pos image", WINDOW_NORMAL );
imshow( imageName, image );
imshow( "neg image", neg_image ); //displaying outputs
imshow( "pos image", pos_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