How to shade the intersection area between two overlay image?

5 次查看(过去 30 天)
I have two overlay image that intersect at two points,my aim is to calculate the area between this two curve.I don't know how to shade the area that is between two curve.this is my program:
RGB=imread('DETECTOR1.PNG');
A=imread('DETECTOR2.PNG');
F=imfuse(RGB,A,'blend','Scaling','Joint');
imwrite(RGB,'Detectors.PNG');
imtool(F);

回答(1 个)

DGM
DGM 2024-10-27,0:28
编辑:DGM 2024-10-27,0:30
JPG screenshots of the ambiguous superposition of working images are not working images.
% the only given image is a screenshot
% it's impossible to tell what the original shapes were
% the claim of 2 intersection points appears to be plainly false
% i'm just going to guess and make my own example images
A = imread('shape_a.png');
B = imread('shape_b.png');
% binarize both images somehow
% i'm already working with single-channel images
A = imbinarize(A);
B = imbinarize(B);
% what is the area of interest?
% is it inside the perimiter or outside?
% does it include the perimeter?
% does it exclude the perimeter?
% i assume it's the interior region including the perimeter
% and that both perimeters are closed paths
A = imfill(~A,'holes'); % fill the perimeters
B = imfill(~B,'holes');
% now both images are binary masks
% unambiguously describing two regions
% assuming that the two images are already registered
% find their intersection
C = A & B;
% area of the images and intersection in px
% convert to whatever units are relevant
areaA = nnz(A)
areaA = 179677
areaB = nnz(B)
areaB = 179677
areaC = nnz(C)
areaC = 168860
% compare the images
imshow([A B C])

Community Treasure Hunt

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

Start Hunting!

Translated by