17
$\begingroup$

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: original image After filter: 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: After gold

How can I correct this digitally and give the background a different colour using Mathematica's built-in functions?

$\endgroup$
4
  • $\begingroup$ Thank you very much for your comments and suggestions. I apologize for a small error. As you can plainly see, the first image is not related to the next two images. I inadvertently attached the wrong original image. Here is a link to the original image As to your suggestions, when I look at the resulting image that you give (top, single), I observe two grey patches in the top of the electrode, and the additional particles to the right of the electrode have not been colored. $\endgroup$
    – user2445
    Sep 27, 2012 at 14:51
  • $\begingroup$ (the rest of Gideon's comment) "As for the suggestions of a different method of binarizing, again I can spot patches of grey where only gold should be, particularly at the center of the image. I could be mistaken, but I think that it is not so simple to color in everything just right, which is what I looking for." $\endgroup$ Sep 27, 2012 at 14:58
  • $\begingroup$ The way of adding colors to the SEM image is presented here youtu.be/IsUW6d1U2yM $\endgroup$
    – user14776
    Jun 5, 2014 at 10:17
  • $\begingroup$ It is an old question, but let me just note: I don't like this subjective colorization method for scientific publications. If you know ahead of time that you might want to colorize the image, it is better to take the EDX map at the same time, and use the EDX data for colorization. This way the colors will be in the right places intrinsically, and even better, correspond to something actually measured rather than someone's artistic impressions. $\endgroup$ Aug 6, 2015 at 18:17

2 Answers 2

18
$\begingroup$

I think there is something wrong in your code. Why did you write # > -300 & as criterion for the area. Lets try another approach with only a simple gaussian filter:

img = ImagePad[
   ColorConvert[Import["https://i.stack.imgur.com/GdtlA.jpg"], 
    "Grayscale"], {{0, 0}, {-100, 0}}];
ImageApply[# {1., 0.843104, 0.} &, img, 
 Masking -> 
  Closing[SelectComponents[Binarize[GaussianFilter[img, 5], 0.464], 
    "Area", # > 1000 &], 3]]

Mathematica graphics

$\endgroup$
14
$\begingroup$

You could try another binarizing function. For example:

mask = MorphologicalBinarize[pq, {.5, 0.6}]
GraphicsRow[{mask, 
 ImageApply[# {1., 0.843104, 0.} &, q, Masking -> mask]}, 
 ImageSize -> 500]

image of two gold things

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.