Classifying different types of hazelnuts

I have 3 different types of hazelnuts: (sample images are attached.)
Type A: Rotten Hazelnuts
Type B: Good Quality Hazelnuts
Type C: Hazelnuts with dark spots of bugs

I also have 2 types of images of these hazelnuts, one is captured by using a filter at 450 nm and the other is captured at 750 nm.

Images are attached for reference.

I am using the Calculator Plus Plugin of ImageJ to perform Image Division by using different values of k1 and k2.

The formula for Division in Calculator Plus is:

Division: i2 = (i1 / i2) * k1 + k2

where i1 is the image taken at 450nm and i2 is the image taken at 750nm.

I have to divide the images in such a way that the bad part of hazelnuts becomes darker (or black) and the good part of hazelnuts becomes lighter (white).

After performing the division, I am using ImageJ’s another feature called “Threshold” in Black and White in order to clearly represent the good and bad parts of the hazelnuts.

I am successful in doing so for Type A and Type C of hazelnuts by using k1=50000.0 and k2=0.0. But I have not achieved good results for Type B by using the same values of k1 and k2.

I have tried to use many different values for k1 and k2 but have not achieved good results because it shows some parts of good hazelnuts as black which is not the required results.

Images are attached for understanding purposes. If someone can give ideas for representing good hazelnuts as white, it would be much appreciated.

All the sample images can be found at the following link:

Thank you.

1 Like

I think the equation you should use is (i1-i2)/(i1+i2). Then do what you wish with the variables k1,k2. I am assuming you are wanting to see the intensity difference . This equation is often used to show the differences much better.