Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snipnet1 #1

Open
lix19937 opened this issue Jun 18, 2023 · 1 comment
Open

snipnet1 #1

lix19937 opened this issue Jun 18, 2023 · 1 comment

Comments

@lix19937
Copy link
Owner

#include <cv.h>
#include <highgui.h>
 
using namespace cv;
using namespace std;
 
#define BLUE 	        0
#define GREEN	1
#define RED 	        2
 
#ifndef SCREEN_XY
#define SCREEN_XY(x, y)  (255 - ((255 - (x))*(255 - (y)) >> 8))
#endif
 
int main(){
	char imgfile[256] = "E:\\t11.jpg";
	Mat src = imread(imgfile, CV_LOAD_IMAGE_COLOR);
	imshow("src", src);
 
	int size = src.cols * src.rows;
	uchar r = 0, g = 0, b = 0, g_alpha = 0;
	uchar *pSrcData = src.data;
	for (int i = 0; i < size; i++, pSrcData += 3)
	{
		g_alpha = 255 - pSrcData[GREEN];
		b = pSrcData[BLUE]*g_alpha  >> 8;
		g = pSrcData[GREEN]*g_alpha >> 8;
		r = pSrcData[RED]*g_alpha   >> 8;
 
		pSrcData[BLUE]  = SCREEN_XY(pSrcData[BLUE],  b);
		pSrcData[GREEN] = SCREEN_XY(pSrcData[GREEN], g);
		pSrcData[RED]   = SCREEN_XY(pSrcData[RED],   r);
	}
 
	imshow("dst", src);
 
	waitKey();
	return 0;
}
@lix19937
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant