Differentiate dark and light areas in image : <p>My problem is that I want to differentiate the light and dark areas in the following image to generate a binary mask.</p>

<p><a href="https://i.stack.imgur.com/7ZRKB.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/7ZRKB.jpg</a></p>

<p>An approximation to the output can be this:</p>

<p><a href="https://i.stack.imgur.com/2UuJb.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/2UuJb.jpg</a></p>

<p>I've tried a lot of things but the results still have some noise or I lost a lot of data, like in this image:</p>

<p><a href="https://i.stack.imgur.com/hUyjY.png" rel="nofollow noreferrer">https://i.stack.imgur.com/hUyjY.png</a></p>

<p>I've used python with opencv and numpy, gaussian filters, opening, closing, etc...
Somebody have some idea to doing this?</p>

<p>Thanks in advance!</p>
