# Connect the nearest points in segmented image

I am trying computer vision for document analysis of datasheets.And quite new to mathematica

My goal is to connect and segment out the part number with part in the drawing considerably something like this. I am able to segment out parts and part number separately but not able to connect them.

Any idea to connect methodically and label out the corresponding segment with part and part number would of great help . Thanks in advance for your time – if I’ve missed out anything, over- or under-emphasised a specific point let me know in the comments.

• It is absolutely not clear, what do start with and what do you want to get in the end. I propose that you show the original and the final drawings, even if they are hand-made. It may be helpful, if you explain where the original image comes from. – Alexei Boulbitch Jul 9 '18 at 8:05
• @AlexeiBoulbitch The first image is the one to start with and the second on is the required output, the third image is the Felzenszwalb's segmentation applied on the first image. The coloured region in the second images show the segmentation area required – Nithin Varghese Jul 9 '18 at 9:00
• It would be significantly easier to provide help if you showed the code you're currently using (and maybe 2-3 more examples, to make sure the code doesn't just get lucky). Otherwise, people might have to redo a significant part of the work you already did to help you – Lukas Lang Jul 9 '18 at 20:04
• As for the actual task at hand, you might be able to do something using ImageLines – Lukas Lang Jul 9 '18 at 20:05
• @LukasLang most of this was done using scikit-image in python that why I didn't share the code. But it's available in here [ dropbox.com/s/6st39w2ioj7m7fn/script.py?dl=0 ] – Nithin Varghese Jul 10 '18 at 4:42