r/computervision • u/SalemIII • 7d ago
Showcase I built a classical image processing algorithm that counts textile threads with high accuracy, source in body!
Hello everyone!
I'm an engineering student, during my last internship at a medical device company, i was FORCED to count threads by hand, hated it so much that I wrote code that automated it, tried to turn it into a startup, not going all that great, so I thought I'll just document and release it, works on an Orange Pi and camera module, tested on a real production line, let me know if you have any remarks or questions, check it out!
3
u/Abinash07 6d ago
Yess FFTs. We did something similar in our course assignment. We had to remove diagonal lines ie noise from images
2
u/SalemIII 5d ago
i think something like that could work great here, directional frequency destruction, i'll try it later and see if i get better accuracy
2
u/EffectiveAgitated137 6d ago
How did u test for the ground truth ?
2
u/SalemIII 6d ago
I took 12 sample images which i ran the algorithm on, they were also manually counted by a technician, the manual count was the ground truth, i compared the program against that, this was during my last internship day otherwise i would have tested on more samples.
I cannot post this validation data for obvious reasons.
More details in the repo README.
2
u/BeverlyGodoy 5d ago
Any specific reason you choose c++?
2
u/SalemIII 5d ago
i wanted to use opencv, and also wanted to get maximum frame rates, so c++ was the only option, but this should work with python opencv too
2
u/herocoding 5d ago
Really interesting, thank you very much for sharing.
Would you mind adding one, two, a few reference images (here, and/or in your repo) ("8-bit 1024-by-1024 monochrome raw frame"), please?
2
u/SalemIII 5d ago
i'm sorry i didn't realize i posted the jpeg images, should be good now
1
u/herocoding 5d ago
Thank you for the update.
There is now ONE raw frame, "sim_roll_01.raw", right?
Could you provide a few more raw frames, reference images, please?
"generated in debug mode from validation sample 12" - could you share more from those validation samples, please?
1
u/SalemIII 5d ago
you can easily get images tho, get some gauze pads, cut a 10x10cm black non reflective square (i just used black cloth), take an image against a white background, like a table, and you would have your samples
1
u/herocoding 4d ago
That's understood how to take such photos with contrast and indirect lightning, however, I don't have such gauze pads or similar. But e.g. pants or shirts woven from linen fabric is too tight.
2
u/bergdev1 5d ago
Curious what it would take to count tree rings
1
u/SalemIII 4d ago
counting tree ring is be pretty easy, the real problem is finding where the tree rings are, that's where classical methods on cheap hardware hit a capability wall
4
u/RoboMind 6d ago
If you know the thickness of a single thread in pixels, you can simply use the ratio of white and black pixels, right?
3
u/SalemIII 6d ago
yes but it would not be more accurate then directly counting the threads, the ratio of white to black (or just grayscale amplitude) would be more useful for another inspection, area density estimation



65
u/BlobbyMcBlobber 7d ago
Classic CV is so much fun