How to detect the difference between two images with random dot pattern
6 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Mahesh Taparia
2019-12-11
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)
Hope it will help.
2 个评论
Mahesh Taparia
2019-12-13
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!