Closed jueqing1015 closed 2 years ago
This is fairly hard to do in a general way, if you have to include arbitrary rotation.
Without significant rotation, it is straightforward. See prog/livre_hmt for how to produce a hit-miss template for locating your pattern in another image.
如果您必须包含任意旋转,这通常很难做到。
没有明显的旋转,它很简单。请参阅 prog/livre_hmt 以了解如何生成命中未命中模板以在另一个图像中定位您的模式。
At the beginning of learning this control, could you please make a small example, excluding rotation thank you very much indeed
Make the hit-miss sel (selhm) in a way similar to what is done in prog/livre_htm.c.
Then do an HMT of your large image, using that structuring element (selhm), and test if there are any ON pixels with pixZero(pix, &empty) [from pix3.c]
If the pattern is found in your larger image, you should get a tight cluster of hits (on pixels) in the HMT at the center location of the sel where the matches occur. To do the HMT, you can use pixHMT() in morph.c.
For example,
pixHMT(NULL, pixbig, selhm);
where selhm is the hit-miss structuring element you generated from your small pattern.
Make the hit-miss sel (selhm) in a way similar to what is done in prog/livre_htm.c.
Then do an HMT of your large image, using that structuring element (selhm), and test if there are any ON pixels with pixZero(pix, &empty) [from pix3.c]
If the pattern is found in your larger image, you should get a tight cluster of hits (on pixels) in the HMT at the center location of the sel where the matches occur. To do the HMT, you can use pixHMT() in morph.c. For example, pixHMT(NULL, pixbig, selhm); where selhm is the hit-miss structuring element you generated from your small pattern.
I feel very much about your patient answer. I have made the basic effect according to your guidance, but now I need to cut down the area found from the large picture. Which part should x, y, width and height be obtained from
When you do the HMT, using the selhm created from your pattern (the smaller image), you do it on the entire large image. The result will be a 1 bpp image the same size as your large image, with foreground pixels at the center location of your selhm in all the places where the selhm matches your large image.
By "matches your large image", I mean that every hit and every miss in selhm has to be matched by hits and misses in the large image.
When you do the HMT, using the selhm created from your pattern (the smaller image), you do it on the entire large image. The result will be a 1 bpp image the same size as your large image, with foreground pixels at the center location of your selhm in all the places where the selhm matches your large image.
By "matches your large image", I mean that every hit and every miss in selhm has to be matched by hits and misses in the large image.
Sorry, my description is wrong. I need to cut the area I found
You need to remove the foreground pixels of the matched pattern from the large image?
If so, you can use pixRasterop(): pixRasterop(pix, x, y, w, h, PIX_CLR, NULL, 0, 0); where x,y is the upper-left corner of the pattern where it matches, and w,h are the pattern dimensions. If the pattern matches at x1, y1, which is the center of the pattern where it matches, then x = x1 - w/2 y = y1 - h/2
For example, I want to use the above two pictures to find the position of the small picture in the large picture. How should I operate