# Read length of lines

**URL:** https://discourse.processing.org/t/read-length-of-lines/1362
**Category:** Processing
**Created:** [June 29, 2018, 2:00pm UTC](https://discourse.processing.org/t/read-length-of-lines/1362 "2018-06-29T14:00:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![disktel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/disktel/32/615_2.png) [@disktel](https://discourse.processing.org/u/disktel)
#### Post date: [June 29, 2018, 2:00pm UTC](https://discourse.processing.org/t/read-length-of-lines/1362/1 "2018-06-29T14:00:12Z")

</div>

Hi,  
i have an image with white background and 2 lines of different color.  
Is it possible with processing to read the length of the lines?  
If yes, can you point out what i have to read/check to make it?  
Thank you

---

<div class="post-metadata">

### Author: ![mat650](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mat650/32/564_2.png) [@mat650](https://discourse.processing.org/u/mat650)
#### Post date: [June 29, 2018, 2:06pm UTC](https://discourse.processing.org/t/read-length-of-lines/1362/2 "2018-06-29T14:06:54Z")

</div>

You first need to find the position for the two end points defining the segment.  
[Definition of Line\_Segment](https://en.wikipedia.org/wiki/Line_segment)  
The way you do that depends on the type of image you have, is it raster or vector?  
Than you can call the method dist(), which calculates the distance given two distinct points.

---

<div class="post-metadata">

### Author: ![disktel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/disktel/32/615_2.png) [@disktel](https://discourse.processing.org/u/disktel)
#### Post date: [June 29, 2018, 2:09pm UTC](https://discourse.processing.org/t/read-length-of-lines/1362/3 "2018-06-29T14:09:26Z")

</div>

Thank you for the reply, raster image.  
So it can done using processing, right?

---

<div class="post-metadata">

### Author: ![mat650](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mat650/32/564_2.png) [@mat650](https://discourse.processing.org/u/mat650)
#### Post date: [June 29, 2018, 2:50pm UTC](https://discourse.processing.org/t/read-length-of-lines/1362/4 "2018-06-29T14:50:44Z")

</div>

It’s not easy if you want to automate the full process because it involves algorithms for edge detection.  
Implementing such algorithm is not an easy task to achieve. 😈  
[Edge detection](https://en.wikipedia.org/wiki/Edge_detection)  
I suggest you to import the raster image as background first. By mouse clicking you can click on the end points of the lines to obtain the coordinates. These can be use to calculate the distance.  
You still need to account the scale problem.

---

<div class="post-metadata">

### Author: ![disktel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/disktel/32/615_2.png) [@disktel](https://discourse.processing.org/u/disktel)
#### Post date: [July 2, 2018, 9:43am UTC](https://discourse.processing.org/t/read-length-of-lines/1362/5 "2018-07-02T09:43:06Z")

</div>

Hi mT650,  
thank you for the reply. I’ll check the edge detection.  
Im trying to automate it without using the mouse or any human interaction.  
I was thinking to have some static points in the image and the count the distance of the line from the static point and on. Lets say like reading the size of bar charts from an image

---

<div class="post-metadata">

### Author: ![mat650](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mat650/32/564_2.png) [@mat650](https://discourse.processing.org/u/mat650)
#### Post date: [July 2, 2018, 10:26am UTC](https://discourse.processing.org/t/read-length-of-lines/1362/6 "2018-07-02T10:26:22Z")

</div>

I’m glad that the information I gave you was helpful,  
and exited to see 🧐 how you will keep up with the most challenging option of the two. 🤟  
Setting up some static points on the raster image is a good way to scale it.
