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:
Thanks in advance.