Finding the Angle of Intersection of elements from two images

7 views (last 30 days)
Ari on 25 Jun 2015
Edited: Ashish Uthama on 26 Jun 2015
I am trying to analyze the intersection points between two skeletonized, binary images.
An example of the two images that need to be compared are as below
First image:
Second image:
Using Imagej I can easily find where all the intersect points are.
However, what I need to do in Matlab is find where these two images intersect and find out at what angle they intersect.
There are many intersection points on each image so it can't be a "manual" process for each intersection.
Once I know the angle of intersection I need to be able to sort the intersection points based on the calculated angle.
Any help is much appreciated! Thanks!
Ari on 25 Jun 2015
Edited: Matt J on 25 Jun 2015
In each of the skeletonized images there are a bunch of lines and if you compare them they intersect at various points (which like you said can be found using the find function). Now, at the intersect point, I want to find the angle at which the line segment from one image intersects with a line segment from the other image (the intersect which caused the overlap). Thanks!

Ashish Uthama on 25 Jun 2015
Edited: Ashish Uthama on 26 Jun 2015
Attached an image (generated by imshowpair).
A rough off the top steps: (assumes the two images are available as logical matrices in im1 and im2)
• Use find(im1&im2) to obtain intersection points
• Since you dont have straight lines, pick a MxN window around a neighborhood of the intersection point to approximate the lines
• For each intersection point
1. Extract an MxN region from each image
2. Fit a line to each set of points in the MxN subregion (tons of ways to do this, search in this form or elsewhere)
3. Determine the angle (tons of ways to do this, search in this form or elsewhere)
Some code to help you get started (I couldn't go further since there are a lot of 'edge' cases that your question does not clarify. The key issue is that the image doest really have 'line' segments, and I am not sure how best to approximate. For example - uncomment the two lines and inspect each nhood - you'll know what I mean)
function t
imshowpair(im1,im2);
N = 10;
%%Find intersection points
%%Extract (2N+1)x(2N+1) window about each intersection point
for ind=1:numel(rInds)
rInd = rInds(ind);
cInd = cInds(ind);
% imshowpair(nhood1,nhood2);
% pause
% Rest of the logic goes here
end
end
Ashish Uthama on 26 Jun 2015
Added a code snippet to get you started.

Categories

Find more on Neighborhood and Block Processing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!