image processing

Hello I wanna make a c++ code for image thresholding.The format of the image is ppm or pgm and and I have to use only the standard library.
I wrote the read and write codes for the image but I need help for the thresholding.
Any help please?
Look at each pixel in the source image.
If pixel value is bigger than threshold_value, set same pixel in output picture to white.
If pixel value is same or less than threshold_value, set same pixel in output picture to black.
thank you very much Moschops! do you have a source code please?
Image processing means the analysis and manipulation of a digitized image, especially in order to improve its quality.
If you wrote the read and write codes, then you have access to individual pixel data in the image.

For each pixel, do as Moschops indicated.


(It is unlikely anyone has the time or desire to write this code for you.)
From your question, I assume you are able to read and write images.

If the image size is Hnum X Vnum, where Vnum is vertical number of pixels and Hnum horizontal number,

You can see an image as a 2D array/matrix with each element having a value, it is intensity for normal image.

Run the for loops like the way you do for 2D arrays and access intensity value at each pixel indexed by horizontal and vertical values. Compare this value to the specified threshold and mark that pixel accordingly.

for example with in the double for loop you can use
(intensity(h,v)>threshold)?pixel(h,v)=white:pixel(h,v)=black;

Be careful in using the correct index values for horizontal and vertical directions.
Please don't beg for code. This forum is for learning, not begging.
Topic archived. No new replies allowed.