This week you’ll improve your solution for last week’s challenge by not only identifying golf balls, but also counting them! Caddie Tom was too impressed with your work and wants to keep collaborating! How complicated is this new task?
Here is the challenge. Let’s use this thread to post our solutions to it, which should be uploaded to your public KNIME Hub spaces with tag JKISeason2-22.
Need help with tags? To add tag JKISeason2-22 to your workflow, go to the description panel in KNIME Analytics Platform, click the pencil to edit it, and you will see the option for adding tags right there. Let us know if you have any problems!
The scaling of the x-axis and y-axis is not necessary, just for faster calculation speed. Converting channels from 3 to 1 can avoid subsequent multi-channel filtering.
If I only counted the number of balls, I found three methods.
I personally prefer the first method, as it can be seen in the interactive view of the “Connected Component Analysis” node that no additional processing is required.Just set the necessary options.
I’ve adapted my solution from last week to loop through images with different numbers of golf balls, including no balls at all.
In my solution, the optimum number of clusters is equivalent to the number of balls. Therefore, I have made a table of results including the original image, a couple of plots and the number of balls column:
After calculating the number of pixels and perimeters of each segment in the image, k-Means clustering was performed to find the segments of golf balls. From the clustering analysis, the segments of cluster_0 are concentrated at almost the same coordinates, suggesting the golf ball cluster. The labeling filter node extracted the segments of cluster_0 from the original image and you see they are eight golf balls. Thank you.
Since in the last challenge I have already defined the number and positions of the objects with native Knime nodes, in the new challenge I decided to experiment a bit more with Segmentize Anything. And actually it works pretty well, since it gives a lot of useful output just out of the box. The only problem is that this model is quite expensive to use. So the output shows the objects in boxes, returns the number of objects and return the box parameters: x, y, width and height.
The code could be optimized, so there is no loop outside of Python script, however it seems to be impossible to gather the images as a table using Python. Or am I missing anything?
As always on Tuesdays, here’s our solution to last week’s Just KNIME It! challenge
It turns out that our solution is not so different from last week’s! After performing image segmentation using the same logic, we went a bit further in the image processing world and used a label filtering technique to identify how many balls there were.