1

I'm trying to detect all the pixels with silver colors in my image. I tried to convert the image from RGB to HSV but I saw that every silver pixel is very different from another and therefore we couldn't identify all the silver pixels. I'm trying to understand if it's possible to use HSV to solve this problem or maybe there is a better way to detect all the silver pixels?

I'm trying to use this code that will mark all the silver pixels in blue:

I chose the Hue,Saturation and Value (HSV) according to wikipedia to identify the silver color, therefore Hue doesn't matter, Saturation is 0-0.1 and Value is 0.65-0.85.

clear all; close all; clc; imtool close all;

im = imread('image.jpg');

size_x = size(im,1);
size_y = size(im,2);
size_z = size(im,3);

hsv = rgb2hsv(im);


for i = 1:size_x
    for j = 1:size_y
        if (hsv(i,j,2) < 0.1) && (hsv(i,j,3) > 0.65) && (hsv(i,j,3) < 0.85)  
            im(i,j,1) = 0;
            im(i,j,2) = 0;
            im(i,j,3) = 255;
        end
    end
end

imtool(im);

with this Image:

https://i.stack.imgur.com/uuhqA.jpg

Thanks in advance.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • Please read: https://stackoverflow.com/help/how-to-ask – amyloula Mar 11 '18 at 13:35
  • What is a “silver pixel”? What code have you used to try to detect them so far? What image are you using? What did you mean that they were “not all silver”? – Fogmeister Mar 11 '18 at 13:55
  • I added the code and the image. When I said that not all the pixels are silver, I meant that not all of them meet the requirement Hue,Saturation and Value as we used from wikipedia. Also, there were pixels that weren't silver but were still marked as blue. I'm trying to identify all the silver pixels and not any other pixels. – אביב עזרא Mar 11 '18 at 14:43
  • What language is that? – Fogmeister Mar 11 '18 at 21:47
  • It's Matlab, but any language will do. – אביב עזרא Mar 12 '18 at 07:46

1 Answers1

0

The difference between a white pixel and a grey pixel is the amount of light that falls on it. You can see this in your picture, the whitish background changes brightness from left to right, going from middle grey to light grey. We perceive it all as white.

The same is true for silver. Silver is a white/grey color, but we perceive it differently because it has specular reflections. This is what characterizes metal surfaces. But the color of the pixels themselves are just grey and white.

That is to say, you cannot use color segmentation to distinguish silver contacts from white paper.

I would suggest you look for the shapes of interest, rather than the colors of interest.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120