I have no knowledge in mathematica, python, and other great softwares.

I saw the following picture in a website;

[![enter image description here](https://i.stack.imgur.com/PHDvD.jpg)](https://i.stack.imgur.com/PHDvD.jpg)

Where a software detects objects (like bus) and tells about its height or width or such things.

---

Well, I work in a chemical laboratory. Cameras are used to take pictures of the samples to be analyzed.

See a real picture:

[![enter image description here](https://i.stack.imgur.com/kRjAA.jpg)](https://i.stack.imgur.com/kRjAA.jpg)

---

Then I need to measure the distance (the black gap). What I always do is to open the image using Paint in my Personal Computer, select the range manually, and take the reading. See the illustration of what I do:

[![enter image description here](https://i.stack.imgur.com/I0vhz.png)](https://i.stack.imgur.com/I0vhz.png)

$549$ in this particular example, (I do not need the height like the $185$) (only width is required).

---

My question now, can mathematica, or any other software, detects those two red vertical lines (which are not in the original image, I put them for illustration purpose) and measure the distance between them in (px)?

---

Some Other examples:

1. Small gap:
[![enter image description here](https://i.stack.imgur.com/d0ALv.jpg)](https://i.stack.imgur.com/d0ALv.jpg)
2. Not a very clear gap. However, the required distance is the one in the middle (not in the left) white/grey-to-white/gray (by averaging) (Errors are accepted up to +/- 5 px). 
[![enter image description here](https://i.stack.imgur.com/W5Zcd.jpg)](https://i.stack.imgur.com/W5Zcd.jpg)

---

If you need me to clarify something, please let me know. I am sorry I do not know English very well. That is the reason.

---

Any help would be really appreciated. Thanks in advance!