Page 1 of 1

How to align 2 images with same but shifted blobs

PostPosted: Fri Jul 19, 2019 11:50 am
by Lexicon
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 1025 times


Offset Image
blobs - Copy (2).png
Offset Blobs
blobs - Copy (2).png (3.9 KiB) Viewed 1025 times

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

PostPosted: Fri Jul 19, 2019 12:03 pm
by andrew.kirillov
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.

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

PostPosted: Fri Jul 19, 2019 12:22 pm
by Lexicon
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?

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

PostPosted: Fri Jul 19, 2019 3:08 pm
by Lexicon
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.

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

PostPosted: Fri Jul 19, 2019 4:10 pm
by andrew.kirillov
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?

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

PostPosted: Sat Jul 20, 2019 8:32 am
by Lexicon
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.