How to detect the difference between two images with random dot pattern

2 Ansichten (letzte 30 Tage)
Hi,
I have generated different paterns using silver ink and I want to write the code which can do following things:
1) in attached images you can see that the patterns are very similar yet very different (randomly distributed. I want to use image processing technique which can efficiently detect the difference between two patterns even they are very similar.
2) Also I want to include the function which can discard all the part of patten which is higher or lower thn certain size and only compare the remaining part of the patern with desired size.
I know that the required function may be available in the image processing toolbox. I tried to find it but I got confuse as there were lots of option and I dont have much knowlwdge about which one to use in my case. If you know somthing can be used please providem me the link with the example of that perticular function.
Thank you in advance

Antworten (1)

Mahesh Taparia
Mahesh Taparia am 11 Dez. 2019
Hi Devarshi
You can directly subtract the images to see their difference. For example:
a=imread('IMG_2035.jpg');
b=imread('IMG_2056.jpg');
c=a-b;
figure;imshow(c)
To remove the portion of image based on size of the connected components, you can use the ‘regionprops’ function of MATLAB. For example:
d= rgb2gray(a);
e=imcomplement(imbinarize(d));
dd=regionprops('table',e,'Area');
ind=find(dd.Area>100); %here 100 is threshold value of area, you can change as per your need
cc=bwconncomp(e);
BW2 = ismember(labelmatrix(cc), ind);
figure;imshow(BW2)
figure;imshow(uint8(BW2).*a)
For more information on regionprops, you can refer to the documentation link.
Hope it will help.
  2 Kommentare
Devarshi Patel
Devarshi Patel am 12 Dez. 2019
Bearbeitet: Devarshi Patel am 12 Dez. 2019
Hi Mahesh,
Thank you for providing the answer.
I already know about the subtracting the images.
These two images are two different identifiers and what I am looking for is to compare them and find out the difference in numerical form and we have the threshold for the particular identifier and the number is above that identifier then it will not be accepted by the program as an authentic identifier.
Furthermore, this pattern will be combined with the color images (attached image 1 and 2) in the final stage and for that the second code (region props) you suggested is helpful. I used regionprop and got the final BW2 image (attached image 3 and 4)
Currently, I am using Structure similarity Index method (SSIM) (link)to compare the BW2 images. As you can see in 3 and 4 there is lots of white area in both the images in same location. Is it possible to only compare the specific region (in this case letter B) as similar background always gives higher similarity.
Please let me know if you need more information from me.
Regards,
Devarshi
Mahesh Taparia
Mahesh Taparia am 13 Dez. 2019
Hi Devarshi,
You can remove the small blobs in the image by setting the proper threshold in the area which can be calculated using regionprops function as mentioned earlier. In this case the letter 'B' is having largest blob by area, so you can keep only the blob with maximum area.
Using ssim function, it will give the index for whole image. To avoid the effect of background, you can take a for loop, consider the pixels of forground. You can use 'find' function to find the coordinates of the letter 'B'. For more information you can refer to the documentation link of find. Calculate the SSIM of foreground pixels using the standard formula which can be found here.
Hope it will help.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by