Ask Your Question
0

change pixels color value

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

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

Comments

2

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 -0600 )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 -0600 )edit
1
berak gravatar imageberak ( 2014-07-11 04:27:58 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

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

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(image.at<type>(i,j) == threshold){
         image.at<type>(i,j) = 255;
      }
   }
}

Good luck!

edit flag offensive delete link more

Comments

thank you

mehddi gravatar imagemehddi ( 2014-07-11 07:17:37 -0600 )edit

Question Tools

Stats

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

Seen: 24,051 times

Last updated: Jul 11 '14