How can I find an approximate intersection of two lines in a binary image?

T
thaka · Mar 3, 2022 · 2.3K views
Question
I'd like to find the coordinates of the intersection of lines in a binary image. What's a good way to do this?
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Aug 24, 2026

I guess I'd try thresholding

binaryImage = grayImage < 128

Then call bwmorph to skeletonize

skelImage = bwmorph(binaryImage, 'skel', inf);

Then call bwmorph again to find crossing points.

crossings = bwmorph(skelImage, 'branchpoints');

This is untested, so give it a shot and let me know how it goes. There is a possibility you could get spurious branchpoints depending on how ragged your thick lines are.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!