Calculate the % contamination rate “black grains” in an image

Hey guys, I need to calculate the contamination rate in grains products (the percentage of thus black grains of the total amount of grains).

the picture is simplified, in real there will be much more black (toxic) grains and much more green (healthy) grains.

my idea was to train a DL algorithm to detect thus black gains and then via area calculation maybe i get the correct percentage.

I appreciate any idea/help ^^

uml

Thanks!

1 Like
  1. train a detection model (like YOLO or SSD) on dark vs light grains
    this would already do the counting for you in the inference.
    drawback: a lot of manual annotations (ground truth boxes/classid for each grain in the pic) nessecary (you probably need some friends to help with the work)

  2. train a classification model on percentages (<10, 10, 20, 30, 40, …) in the whole image

in any way, you will need a LOT of images, so start collecting now.
also look out for pretrained networks for similar cases, you might be able to re-train it on your problem (with significantly less data than originally)

Thank you for reply :)), I am collecting images and will train YOLO algorithm, if my algorithm detects all thus dark grains, how i can get their % weight from total weight ? total weight is known

you count the detected black classids and divide by total detection count :wink:

what ? how so ? explain, please

i can measure total weight of grains with a balance, lets be for example 500 g ,

the % of dark grains will be around 1-4 %, i need to get the exact %

actually, you can only see grains in a 2d image, not weight them
you can get a percentage of dark grains wrt. to all visible grains, though

that kinda rules out the classification idea, finding the difference between 2 or 3 % is unlikely to work.