Gimp-Forum.net
counting pixels - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: counting pixels (/Thread-counting-pixels)



counting pixels - momara - 03-27-2018

Hello,
Total newbie here and using Gimp for scientific purposes.  We are following some past work of scientist testing digital photos to determine vegetation cover (obstruction from view).  Two author groups used Gimp to analyze their photos (pre 2013).  I am unable to recreate their procedures and can't figure out on my own how to count pixels.  I have hundreds of photos of grasses and plants taken with a black backdrop.  What I need to do is find the ratio of black pixels (the black backdrop) to other pixels (plants).  I tried using Threshold to change to BW then using Histogram.  I 've also tried using just Histogram.  I've tried a bunch of different ways to get to a pixel count.  I'm either missing a step or two or am just not understanding the results I'm getting.  HELP!!!  I can send an image if that helps.
Thank you,
Mo


RE: counting pixels - rich2005 - 03-27-2018

Should work using Colours -> Info -> Histogram

A made up 800x800 image - histogram shows number of pixels https://i.imgur.com/ilnybYg.jpg

Colour-select the black for the number of pixels https://i.imgur.com/Xsoivt7.jpg


RE: counting pixels - rich2005 - 03-27-2018

Have you considered using ImageJ https://imagej.nih.gov/ij/

Slightly different result, it will be due to the Gimp selection.

Change the image convert to binary, check the histogram

looks like https://i.imgur.com/SUOu8Wu.jpg

---------------
edit: In fact that might be the way to go in GIMP

'Colors -> Threshold` to make the image binary

Then in the histogram move the slider over to the left

Gives the number and percentage straight off. https://i.imgur.com/z9Tauju.jpg


RE: counting pixels - momara - 03-27-2018

(03-27-2018, 05:09 PM)rich2005 Wrote: Should work using Colours -> Info -> Histogram

A made up 800x800 image - histogram shows number of pixels https://i.imgur.com/ilnybYg.jpg

Colour-select the black for the number of pixels https://i.imgur.com/Xsoivt7.jpg

Thanks, this helps me understand how to get pixel counts by selecting colors on the pic.  Even though we used a black background, there are variations of black due to light.  So I still can't get a complete count of black pixels.   I tried this technique in histogram after applying the threshold tool, but obv. I'm not understanding what threshold is for or how to use it because I cant count pixels of black or white.

If I can't figure out a way with Gimp I will try the other source you sent.  I have to go through justifications and  admn approvals and downloads for any software, even to just try it to see if it works, so I have to keep trying Gimp.

Mo


RE: counting pixels - momara - 03-27-2018

(03-27-2018, 05:29 PM)rich2005 Wrote: Have you considered using ImageJ https://imagej.nih.gov/ij/

Slightly different result, it will be due to the Gimp selection.

Change the image convert to binary, check the histogram

looks like https://i.imgur.com/SUOu8Wu.jpg

---------------
edit: In fact that might be the way to go in GIMP

'Colors -> Threshold` to make the image binary

Then in the histogram move the slider over to the left

Gives the number and percentage straight off. https://i.imgur.com/z9Tauju.jpg

Thank you for the edit remarks. I think this will work. Visually, it comes out to the same percentage of white that I calculate from the difference between the white and black pixels. Now to check with the higher ups.

Thanks again!
Mo


RE: counting pixels - Ofnuts - 03-28-2018

Actually using Windows>Dockable dialogs>Histogram alone, you can move the two handles to define a range. The range depends on the histogram shown, it can be the "value" (biggest of the R,G, and B channels) or any of the three channels.
[attachment=1598]



RE: counting pixels - momara - 03-28-2018

Thanks for the suggestion. I had played around in Historgram, but I have so many variations of the color black (due to how light hit the black board). I couldn't figure out a way to make sure I wasn't eliminating that lighter background.