07-17-2023 01:36 PM
Hello All,
I am working on a program (attached image 6) to highlight all dot peen holes in black color with everything rest as white background. Attached image 2 shows all the holes highlighted in red square but I am not sure how to add rectangle/square at each of the highlighted location. I want to make a square/rectangle/circle at each location of the hole (as per image 2) and fill that rectangles with black color and the background to be white. The final image must look like image 3 attached. I have locations of all the holes as you can see in image 6 right side. Any help is appreciated. Thanks
Solved! Go to Solution.
07-17-2023 04:51 PM
Hi VeMo,
I would suggest you to recreate a new image from scratch using:
- "IMAQ Create.vi" using image type "Grayscale (U8)".
- Then "IMAQ ArrayToImage.vi" by feeding an array of the same size as the original image and with all its values to 255 (white).
- Then "IMAQ Draw.vi" by converting the pattern matching results to an array of coordinates for each circle to draw, with color 0 (black).
- Display your image and voilà !
Attached is an example based on your images:
Note: here the pattern matching is not well tuned as not all dot peen holes are detected.
Also, trying to read the generated data matrix with "IMAQ Read Data Matrix Barcode.vi" did not succeed. I guess the parameters must be tuned and the generated data matrix must be adjusted with proper size and quiet zone size...
Regards,
Raphaël.
07-17-2023 05:51 PM
Hi Raphael
thank you so much for your help.
I tried with other image with the program you sent but it didn't work. I tried changing the dot peen pattern.png but still it is not making same data matrix image as the original image is making. Am I doing something wrong? I am still new with LabVIEW so trying to learn. Below are different image with what you used previously and they don't create anything. Do you recommend me to try something different?
Thanks
VeMo
07-18-2023 02:38 AM
Hi,
Since you posted an image with all the dot peen holes with their positions already detected, I assumed this part of the process was already understood and functional.
Here it seems your pattern image has an invalid template descriptor. You must either train it with the Pattern Matching template editor in Vision Assistant, or load it as a plain png in LabVIEW (without vision info) and train it on-the-fly with "IMAQ Learn Pattern".
07-18-2023 11:44 AM
"Since you posted an image with all the dot peen holes with their positions already detected, I assumed this part of the process was already understood and functional." -- Yes, I already have a program made that locates all/almost all the holes of the dot peen pattern on a metal plate.
"Here it seems your pattern image has an invalid template descriptor. You must either train it with the Pattern Matching template editor in Vision Assistant, or load it as a plain png in LabVIEW (without vision info) and train it on-the-fly with "IMAQ Learn Pattern"." -- Sorry, I don't understand this point. Because the images I sent you yesterday, the pattern image was extracted from the original image I was trying to locate holes on so it is from the same image.
I can send you my program to locate holes if you think that is going to give you more information to help me. Let me know please.
Thanks
07-19-2023 06:43 AM
@VeMo a écrit :
Yes, I already have a program made that locates all/almost all the holes of the dot peen pattern on a metal plate.
So use this program instead of my pattern matching, I have just redone it as an example to generate realistic hole positions as an input for the drawing.
@VeMo a écrit :
Sorry, I don't understand this point. Because the images I sent you yesterday, the pattern image was extracted from the original image I was trying to locate holes on so it is from the same image.
Extracting the image is not sufficient, it has to contain metadata (vision info) that describe the content of the pattern.
It can be done using 2 different ways:
- with Vision Assistant (shipped with NI Vision). On a grayscale image, add a Pattern Matching step. Then there is a built-in editor that allows you to extract a sub-image from the current image and save it as a pattern usable by the algorithm. The image will contain the mentioned vision info metadata.
- directly in LabVIEW, by using "IMAQ Learn Pattern". This has to be called before "IMAQ Match Pattern" and will dynamically add the vision info metadata to the pattern image.
I wrapped the code that answers your initial question (namely: how to draw the data matrix), so that you can better identify it among the rest of the code:
I also updated the test code to use the subVI and added a "Learn" to allow you to load an untrained pattern image.
Regards,
Raphaël.
07-19-2023 11:12 AM
Thank you so much Raphael.
I was actually able to follow your suggestion from yesterday and make it work. See attached pictures. I was able to generate data matrix but the only concern is that the boxes are not aligned properly. If you see the edges, they are not straight and I was wondering if there is a way to correct this issue?
Today I will look at your new program and see if there is more I can add to my current program to modify it to make it better than what it is currently. Also, I will try today to add some more vi's to read data matrix code as it is important step of my process as well.
I appreciate all the help from you.
Thanks
VeMo
07-19-2023 04:40 PM
Hello Raphael,
I was able to make it work and the program reads data matrix encoded message as well. See Image 1 attached. Thank you for your help.
I tried using the program to find a specific pattern in an image but it does not work. What I mean by that is, I have a specific template/design that I want to find in an image regardless of everything else in the background. So for example in image 6 there are three black rings design/template. If you see image 2, image 3, image 4, image 5, these black rings are hidden in either mountain, ocean, grass etc. If I use the program, I cannot find these three rings in any image (I think it is because of different background and the template image was not taken from original image). Would you have an idea how can I edit the program to find a default template in any random image that I have if it includes that particular design?
The reason I am asking this is because currently we are taking template image from the actual image of the dot peened metal but what if I want to take a template image and keep it fixed and I have 100's of different dot peen images that I want locate holes on. It will not be convenient to manually select template image all the time so if there is a vi that I can use and feed a default design that I am looking for (in attached example case three black rings) in any image I upload, that will be easy and good. Let me know if you need more clarification.
Thanks
VeMo