The fact that his JPEG image will produce “blocking” artifacts, which in the example above cause most of the square areas around the veins to have a lot of noise, so it’s ideal to work with an image that did not have compression loss. If this is not possible, try filtering the image to remove some of the noise.
The veins you want to extract have a different color from the background, leaf, and shadow, so some threshold based on color might be a good idea. There was a recent S.O. question with some code that might help here . After that, some kind of adaptive normalization will help increase the contrast before you reach the threshold.
[edit]
Perhaps the threshold is not an intermediate step that you want to take. I did the following, filtering to remove jpeg artifacts, doing some CMYK math channel (bluer and blacker), then applying adaptive alignment. I’m sure that you could continue to produce (possibly sub-pixel) edge points using image gradients and suppress non-maximum numbers, and perhaps use the brightness at each point and the properties of the vein structure (mainly tangential joining) to attach the dots to the lines .
source share