Created
May 26, 2013 21:11
-
-
Save b-oern/5654045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <opencv2/core/core.hpp> | |
#include <opencv2/highgui/highgui.hpp> | |
using namespace cv; | |
int main( int argc, char** argv ) { | |
Mat image; | |
image = imread( argv[1], 1 ); | |
if( argc != 2 || !image.data ) { | |
printf( "No image data \n" ); | |
return -1; | |
} | |
Mat new_image = Mat::zeros( image.size(), image.type() ); | |
double alpha = 1.5; | |
double beta = 75; | |
/// Do the operation new_image(i,j) = alpha*image(i,j) + beta | |
for( int y = 0; y < image.rows; y++ ) { | |
for( int x = 0; x < image.cols; x++ ) { | |
for( int c = 0; c < 3; c++ ) { | |
new_image.at<Vec3b>(y,x)[c] = saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta ); | |
} | |
} | |
} | |
imwrite("alpha.jpg", new_image); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment