Ask Your Question

change pixels color value

asked 2014-07-10 16:05:14 -0500

mehddi gravatar image

hi everyone i want to change some pixels values based on special condition. for instance if value of a pixel is 75, set it to zero or some another values. i use opencv in c++ and use IPLimage for processing images in program. i want to use this idea for detect unnecessary areas and eliminate them. thank you.

edit retag flag offensive close merge delete



now try again, please; explain it to a 5 year old (and avoid IplImages, they died in 2010)

(if you did not find out yet, what replaced them, - there's work for you...)

berak gravatar imageberak ( 2014-07-10 16:10:11 -0500 )edit

in grayscale images any pixels have values between 0 and 255, OK? i want to get this values and set them by desired values.

mehddi gravatar imagemehddi ( 2014-07-11 03:16:06 -0500 )edit
berak gravatar imageberak ( 2014-07-11 04:27:58 -0500 )edit

thanks a lot! i find my answer. i am new in opencv and this tutorials is great for me.

mehddi gravatar imagemehddi ( 2014-07-11 07:16:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-07-11 07:00:38 -0500

Simply said, you need to work yourself into getting familiar with OpenCV like @berak suggested. Questions like this can be solved by simply performing 1 or 2 tutorials and getting the hang of everything. That said, the following pseudocode needs to be formed to your problem but it illustrates the desired functionality.

Mat image;
for(int i = 0; i < image.rows; i++){
   for(int j=0; j < image.cols; j++){
      //apply condition here
      if(<type>(i,j) == threshold){<type>(i,j) = 255;

Good luck!

edit flag offensive delete link more


thank you

mehddi gravatar imagemehddi ( 2014-07-11 07:17:37 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-07-10 16:05:14 -0500

Seen: 17,698 times

Last updated: Jul 11 '14