Finding the Angle of Intersection of elements from two images
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ari
el 25 de Jun. de 2015
Editada: Ashish Uthama
el 26 de Jun. de 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!
2 comentarios
Ashish Uthama
el 25 de Jun. de 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?
Respuesta aceptada
Ashish Uthama
el 25 de Jun. de 2015
Editada: Ashish Uthama
el 26 de Jun. de 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
- Extract an MxN region from each image
- Fit a line to each set of points in the MxN subregion (tons of ways to do this, search in this form or elsewhere)
- 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 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!