Ask Your Question
0

BGR pixel transformations

asked Feb 7 '15

Evoxz gravatar image

updated Feb 7 '15

Hi :) I'm searching for a function wich is able to get the BGR data of any pixel (with the X/Y coordinates of this pixel) and change it. Do you know something about a function like that? I program in C++.

Best regards, Evoxz

Preview: (hide)

Comments

See an example here

Haris gravatar imageHaris (Feb 7 '15)edit

1 answer

Sort by » oldest newest most voted
3

answered Feb 7 '15

jamesnzt gravatar image

updated Feb 7 '15

berak gravatar image
Mat img=imread("<<filename>.<extension>>",CV_LOAD_IMAGE_COLOR);

int i=;//row pixel co-ordinate;
int j= ;//coloumn pixel co-ordinate;
Vec3b intensity = img.at<Vec3b>(i,j);
float blue=intensity.val[0];
float green=intensity.val[1];
float red=intensity.val[2];

the variables blue,green and red contains the BGR value.

Preview: (hide)

Comments

Thanks a lot! :) And how can I do to change these values?

Evoxz gravatar imageEvoxz (Feb 7 '15)edit
1

@Evoxz, use a reference: Vec3b & pixel = img.at<Vec3b>(i,j); pixel.val[1] = 17;

berak gravatar imageberak (Feb 7 '15)edit

Question Tools

1 follower

Stats

Asked: Feb 7 '15

Seen: 327 times

Last updated: Feb 07 '15