INTERSECTION BETWEEN 2 IMAGES

25 ビュー (過去 30 日間)
francesco
francesco 2014 年 2 月 27 日
編集済み: Image Analyst 2021 年 9 月 15 日
Hi everyone (sorry for bad english).
I need code to find the intersection between two images. I have image A and image Am (is the modified version of image A) and I have to find points in common or the area (teacher suggest I use the intersection). Then repeat the process for 100 images in a folder.

回答 (3 件)

Image Analyst
Image Analyst 2014 年 2 月 27 日
編集済み: Image Analyst 2021 年 9 月 15 日
You can subtract them and look for 0's. For grayscale images:
matchingPixels = (double(image1) - double(image2)) == 0;
imshow(matchingPixels);
To find area of matching pixels, you can use sum(), bwarea() or regionprops():
area1 = sum(matchingPixels);
area2 = bwarea(matchingPixels);
% To use regionprops to find areas of all matching regions.
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area');
area3 = sum([measurements.Area]);
For color images, you have to check each color channel for matches.
For binary images use the dice() function, introduced in R2017b:
Description
similarity = dice(BW1,BW2) computes the Sørensen-Dice similarity coefficient between binary images BW1 and BW2.
  2 件のコメント
Diah Junaidi
Diah Junaidi 2019 年 8 月 1 日
what should I do for sir? i have 2 binary images that I wanna compare.
labeledImage = bwlabel(binaryImage);
Image Analyst
Image Analyst 2019 年 8 月 2 日
編集済み: Image Analyst 2021 年 9 月 15 日
In what way do you want to compare these binary images? Maybe:
Description
similarity = dice(BW1,BW2) computes the Sørensen-Dice similarity coefficient between binary images BW1 and BW2.

サインインしてコメントする。


Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 27 日
編集済み: Azzi Abdelmalek 2014 年 2 月 27 日
[M,ii,jj]=intersect(A,Am)

Mohsin Khalid
Mohsin Khalid 2016 年 9 月 20 日
編集済み: Mohsin Khalid 2016 年 9 月 20 日
1) Convert them in to gray scale images 2) Then convert them in to binary images
Below is a command for intersection of two images
intersectedImage=bitand(binaryImage1,binaryImage2);
For 100 images take the intersectedImage and bitand it with binaryImage3 and so on..
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 20 日
If you take that approach, the output will only be set at places where both images had intensity greater than or equal to 128 (out of 255), which is not what the user is asking. The user is asking for points that are in common, which includes places where both are both the same low intensity.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by