I have an image of gold electrodes on a flat substrate obtained with a scanning electron microscope. I would like to colour in all the gold electrodes and particles that appear in the center of the image and make the background a different colour.
I'm trying to use some straightforward processing; applying PeronaMalikFilter
to enhance the edges and diffuse the background:
q=Image;
pq = PeronaMalikFilter[q, 20, 0.02, 2]
Original image:
After filter:
The background in the image thus obtained looks more diffused and uniform, while the edges of the gold electrodes and particles appear sharp, in contrast to the background. Then I give the following command to colour in the gold:
goldq = ImageApply[# {1., 0.843104, 0.} &, q,
Masking -> SelectComponents[Binarize[pq, 0.36], "Area", # > -300 &]]
The result is an image in which the gold electrodes are almost entirely coloured in gold, but there are also large regions that are coloured by gold, which shouldn't be; for instance, the left side of the image, and the top right and bottom right. It seems that these areas are coloured due to the fact that they have the same binary level as the actual gold electrodes, which is an artifact of the scanning, and should definitely have the same zero level as the rest of the background.
After gold:
How can I correct this digitally and give the background a different colour using Mathematica's built-in functions?