Ask Your Question
1

How can I work with pixels of an image directly?

asked 2013-03-13 01:38:47 -0500

hor gravatar image

updated 2015-11-08 14:00:09 -0500

Hi , I want to work with pixels of an image directly . For example , reading the pixel values(like R,G,B) or pixel locations(X,Y) and I can change them or write some functions to use of them .

How can i do that?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-03-13 02:51:25 -0500

Daniil Osokin gravatar image

Hi! For this purposes OpenCV has Vec classes. For example, you can access to pixel at (x,y) position like this:


// image is a Mat with CV_8UC3 type
Vec3b pixel = image.at<Vec3b>(x, y);

Also, you can use Mat_ instead of Mat to do this in a shorter way:


// image is a Mat_ with CV_8UC3 type
Vec3b pixel = image(x, y);
edit flag offensive delete link more

Comments

1

Thanks a lot Daniil I will check it tomorrow and tell you about results(unfortunately today i cant)

hor gravatar imagehor ( 2013-03-13 04:21:55 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-03-13 01:38:47 -0500

Seen: 721 times

Last updated: Mar 13 '13