AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

How to align 2 images with same but shifted blobs

The forum is to discuss topics related to different areas of image processing and computer vision.

How to align 2 images with same but shifted blobs

Postby Lexicon » Fri Jul 19, 2019 11:50 am

Hi Andrew,

I have a master image with a few blobs which I want to match with other images. I tried ThresholdDifference filter which works great at identifying difference between 2images and highlighting them when both images have blobs at exactly the same place. But I have a few images where the blob pattern is same as template, but its a bit offset. In this case, all the blobs are identified as different.

How do I align such images with the template image so that only the difference is highlighted instead of every blob.

Master Image Template
blobs.png
Master Template
blobs.png (3.93 KiB) Viewed 1077 times


Offset Image
blobs - Copy (2).png
Offset Blobs
blobs - Copy (2).png (3.9 KiB) Viewed 1077 times
Lexicon
 
Posts: 4
Joined: Fri Jul 19, 2019 11:43 am

Re: How to align 2 images with same but shifted blobs

Postby andrew.kirillov » Fri Jul 19, 2019 12:03 pm

Hello,

Here is one simple way to try. Suppose you have an object, which is not supposed to change between template and other images. Let’s assume it is a top left object on your images. When you do Blob Counting, it provides you with coordinates of each object. So if the object you want to use for alignment has coordinates (X1,Y1) in template, but (X2, Y2) in another image, then calculating shift is just subtracting those coordinates. It may work only if you can guarantee you have a reference object, which does not change in size/shape.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3451
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: How to align 2 images with same but shifted blobs

Postby Lexicon » Fri Jul 19, 2019 12:22 pm

Hi Andrew,

Yes, the image is from a blister pack. It does have a punched hole in every pack which can be used as a reference. I did get the coordinates as you mentioned, but how do I use it to align images and then perform thresholddifference?
Lexicon
 
Posts: 4
Joined: Fri Jul 19, 2019 11:43 am

Re: How to align 2 images with same but shifted blobs

Postby Lexicon » Fri Jul 19, 2019 3:08 pm

Hi Andrew,

I tried canvas move, and it works great for most of the images. But i needed something more robust and i found the movetowards filter. But after I apply the filter im getting a transparent overlay on the source image instead of move image. Im trying to get a perfectly aligned/overlapped image for accuracy.
Lexicon
 
Posts: 4
Joined: Fri Jul 19, 2019 11:43 am

Re: How to align 2 images with same but shifted blobs

Postby andrew.kirillov » Fri Jul 19, 2019 4:10 pm

Move Towards is completely for different purpose - check docs.

Canvas Move is the right tool. When you say it works for most, but not for all, what do you mean? What is the issue with that?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3451
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: How to align 2 images with same but shifted blobs

Postby Lexicon » Sat Jul 20, 2019 8:32 am

Hi Andrew,

Sometimes the blob in the image is a bit warped due to bend in the actual component area. In this case canvas moves align the image with the template but the blobs with slight warping is seen as different even though its good in reality.
Lexicon
 
Posts: 4
Joined: Fri Jul 19, 2019 11:43 am




Return to Image Processing and Computer Vision

cron