Finding the Angle of Intersection of elements from two images

2 Ansichten (letzte 30 Tage)
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!
  2 Kommentare
Ashish Uthama
Ashish Uthama am 25 Jun. 2015
Ari, mind explaining a bit more? Its easy enough to find the indices of all points which over lap from the two images (provided they are the same size) - find(im1&im2) - is that what you mean by intersecting points?. How do you define an angle of intersection for these points?
Ari
Ari am 25 Jun. 2015
Bearbeitet: Matt J am 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!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ashish Uthama
Ashish Uthama am 25 Jun. 2015
Bearbeitet: Ashish Uthama am 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
  • Pad both images by M and N padarray
  • 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
im1 = im2bw(imread('/tmp/1.jpg'));
im2 = im2bw(imread('/tmp/2.jpg'));
imshowpair(im1,im2);
%%Pad
N = 10;
im1Pad = padarray(im1,[N N], 'both');
im2Pad = padarray(im2,[N N], 'both');
%%Find intersection points
[rInds, cInds] = find(im1Pad&im2Pad);
%%Extract (2N+1)x(2N+1) window about each intersection point
for ind=1:numel(rInds)
rInd = rInds(ind);
cInd = cInds(ind);
nhood1 = im1Pad(rInd-N:rInd+N, cInd-N:cInd+N);
nhood2 = im2Pad(rInd-N:rInd+N, cInd-N:cInd+N);
% imshowpair(nhood1,nhood2);
% pause
% Rest of the logic goes here
end
end
  2 Kommentare
Ari
Ari am 25 Jun. 2015
How do I pick an MxN window around the intersect point without using something that has to be done manually like roipoly? (Bullet point #2)
Ashish Uthama
Ashish Uthama am 26 Jun. 2015
Added a code snippet to get you started.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by