Ask Your Question
0

change pixels color value

asked Jul 10 '14

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.

Preview: (hide)

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 (Jul 10 '14)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 (Jul 11 '14)edit
1
berak gravatar imageberak (Jul 11 '14)edit

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

mehddi gravatar imagemehddi (Jul 11 '14)edit

1 answer

Sort by » oldest newest most voted
2

answered Jul 11 '14

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!

Preview: (hide)

Comments

thank you

mehddi gravatar imagemehddi (Jul 11 '14)edit

Question Tools

Stats

Asked: Jul 10 '14

Seen: 24,105 times

Last updated: Jul 11 '14