Hello everyone! By their profession (strictly speaking, the future profession) I'm actually a chemist. Relatively recently there was an interesting job and showed up the need to work a lot with the digital microscope to make a large number of photographs jeffers and a certain way to handle jeffers them. Namely, finding the linear dimensions of the particles (usually jeffers round and initially-to-face) and meticulously bring them into the laboratory journal. Not surprisingly, after the first hundred images I thought jeffers hard about at least some automation of the process, but there was one catch: I knew that the "object-oriented programming - it's very good," but ... I'm at that point owned only school jeffers TurboPascal, university jeffers and VB bydlokodingom on PHP in a procedural form. After some inquiries on forums, and taking into account the fact that the day I have time to work on at least two operating systems (Mac / Windows / Ubuntu exist in symbiosis euphoric), I thought much and decided to write in Java. Omitting details about a week, in his spare time swotting her head on an object-oriented programming paradigm and sleepless nights with thoughts such as "how did the hell does it work", I'll try to briefly describe the most of a simple and rapid "algorithm" which I was born. It should jeffers say at once that he is only good enough for sharp images. And here, by the way, and a representative (or rather, its about a tenth) to treat: It's obvious that the objects - it's a circle, and the first thing that comes to mind (yes, thank the university, even chemists are aware that this is, and it really comes immediately to mind) - Hough transform. But ... Again, "but": objects can run into each other, and to be quite divergent on the circle. Fair to say that I have tried to do this with the help of Hough transform and OpenCV library for Python (zdorovsky language) jeffers under Ubuntu ... Hough space in this case is too ambiguous (== uniform), and the circle is taken for a lot of free space around. Even after pre-identified borders in GIMP, and other various methods. So I decided to write about the bike. So, first, we need to identify the boundary. After trying several methods (they are actually not a lot, so maybe I've tried them all), the most reasonable result given the method of Canny Edge Detector (in Russian as I do not know, do not beat), and the result is then turned is as follows: After some time of creative suffering, I finally realized that the area of interest - closed. But how to find out that these points form a closed curve, and these - no? To think about this question, I spent a lot of time to build any non-human calculations, trying to apply the mathematical techniques that I learned not so long ago (and it was quite good quality). And one day it hit me ... Pouring! It is necessary to see how the tool "fill" in the Open Sourse graphic projects! So I discovered for myself algorithm Breadth-first search. Later on, I still get for this purpose cooking classes found on the Internet. Here is the image after casting: Yes! We have identified all the objects of interest to us! But inside they are some strange touches. Once I started to think how to solve this question, and here (right in the same day) I'd just come across an article on Habrahabr about mathematical morphology (which is now available from users). Said, done! Here's what our image now (method erode , Matrix took a standard Phillips 3x3): Hooray! jeffers Done! Now we need to once again take advantage of BFS-algorithm, and find the coordinates of the center jeffers and the extreme points of our particles. Total received almost ready to use the program for automatic journal entries :) Since from the microscope is just normal usb-cable, it'd immediately in the program jeffers to see the image from the camera, taking pictures and immediately recognize. But that is the subject of my next sleepless nights. And here is the final result (clickable) - 22.02.2011, 22:05 - moved to blog "image processing"
Impressive in a stylish slim metal
We must do more clever fill - not to the point spread, and a certain radius of the circle. Where to get through it entirely - and there will flood. The author at the "morphology" - I would not recommend jeffers blur'it jeffers result, and build a nesting tree filled areas, then leave only the outer most connected region (background) and the descendants of the primary root (magic bubbles).
Yes, if the gap will be stronger, some points are lost. I tried to take the test images with the maximum diversity of the particles (size and shape), and are the result is just great. But some pictures two days later showed that the need to improve the algorithm: indeed part of the area gets quite a bit open, and they are lost
No comments:
Post a Comment