How To Track the brown color of the hand of the image? please help me

2 views (last 30 days)
How Do I trace? or track? the brown color of the hand of the image? which is capture during the snapshot and my background is white? then crop automatically the hand? I am currently doing Hand Signal Recognition..I get a program from my friend but a little bit confusing how to configure the code since my background is white and his background is blue i guess...see this link for the image

Answers (2)

Image Analyst
Image Analyst on 6 Feb 2012
Lots of tracking info on the Mathworks web site:
  1 Comment
john john
john john on 6 Feb 2012
those tracking info link you give to me sir are just common problems? can u help me with the code below how it was done?

Sign in to comment.


john john
john john on 6 Feb 2012
This is the Code I got from my old friend, can you help how to configure those code? if would be okay?
asdfg_count = 0;
x_orig = x;
orange = x;
%special part convert blue to white (bg)
image_size = size(orange);
a1 = image_size(1,1);
a2 = image_size(1,2);
for aa1=1:a1,
for aa2=1:a2,
%track blue
if (((orange(aa1,aa2,1) >= 0) && (orange(aa1,aa2,1) <= 77))...
&& ((orange(aa1,aa2,2) >= 0) && (orange(aa1,aa2,2) <= 97))...
&& ((orange(aa1,aa2,3) >= 39) && (orange(aa1,aa2,3) <= 255)))
orange(aa1,aa2,:) = 255;
end
end
end
x = orange;
%upper side
image_size = size(x);
a1 = image_size(1,1);
a2 = image_size(1,2);
fire_r = 0;
for aa1=1:a1,
for aa2=1:a2,
%track brown
%if (((x(aa1,aa2,1) >= 127) && (x(aa1,aa2,1) <= 187))...
% && ((x(aa1,aa2,2) >= 82) && (x(aa1,aa2,2) <= 150))...
% && ((x(aa1,aa2,3) >= 60) && (x(aa1,aa2,3) <= 120)))
%track white
if (((x(aa1,aa2,1) >= 0) && (x(aa1,aa2,1) <= 240))...
&& ((x(aa1,aa2,2) >= 0) && (x(aa1,aa2,2) <= 240))...
&& ((x(aa1,aa2,3) >= 0) && (x(aa1,aa2,3) <= 240)))
fire_r = aa1;
break;
end
end
if fire_r ~= 0
break;
end
end
if fire_r == 0
fire_r = 1;
end
x2 = zeros(a1 - fire_r,a2,3);
ab1 = 1;
for aa1=fire_r:a1,
for aa2=1:a2,
x2(ab1,aa2,1) = x(aa1,aa2,1);
x2(ab1,aa2,2) = x(aa1,aa2,2);
x2(ab1,aa2,3) = x(aa1,aa2,3);
end
ab1 = ab1 + 1;
end
%side left
x2 = uint8(x2);
image_size = size(x2);
a1 = image_size(1,1);
a2 = image_size(1,2);
fire_c = 0;
for aa2=1:a2,
for aa1=1:a1,
%track brown
%if (((x2(aa1,aa2,1) >= 112) && (x2(aa1,aa2,1) <= 187))...
% && ((x2(aa1,aa2,2) >= 95) && (x2(aa1,aa2,2) <= 152))...
% && ((x2(aa1,aa2,3) >= 77) && (x2(aa1,aa2,3) <= 80)))
%track white
if (((x2(aa1,aa2,1) >= 0) && (x2(aa1,aa2,1) <= 240))...
&& ((x2(aa1,aa2,2) >= 0) && (x2(aa1,aa2,2) <= 240))...
&& ((x2(aa1,aa2,3) >= 0) && (x2(aa1,aa2,3) <= 240)))
fire_c = aa2;
break;
end
end
if fire_c ~= 0
break;
end
end
if fire_c == 0
fire_c = 1;
end
x3 = zeros(a1,a2 - fire_c,3);
ab2 = 1;
for aa2=fire_c:a2,
for aa1=1:a1,
x3(aa1,ab2,1) = x2(aa1,aa2,1);
x3(aa1,ab2,2) = x2(aa1,aa2,2);
x3(aa1,ab2,3) = x2(aa1,aa2,3);
end
ab2 = ab2 + 1;
end
%side right
x3 = uint8(x3);
image_size = size(x3);
a1 = image_size(1,1);
a2 = image_size(1,2);
fire_c = 0;
for aa2=a2:-1:1,
for aa1=a1:-1:1,
%track brown
%if (((x3(aa1,aa2,1) >= 127) && (x3(aa1,aa2,1) <= 187))...
% && ((x3(aa1,aa2,2) >= 82) && (x3(aa1,aa2,2) <= 150))...
% && ((x3(aa1,aa2,3) >= 60) && (x3(aa1,aa2,3) <= 120)))
%track white
if (((x3(aa1,aa2,1) >= 0) && (x3(aa1,aa2,1) <= 240))...
&& ((x3(aa1,aa2,2) >= 0) && (x3(aa1,aa2,2) <= 240))...
&& ((x3(aa1,aa2,3) >= 0) && (x3(aa1,aa2,3) <= 240)))
fire_c = aa2;
break;
end
end
if fire_c ~= 0
break;
end
end
if fire_c == 0
fire_c = a2;
end
x4 = zeros(a1,fire_c,3);
ab2 = 1;
for aa2=1:fire_c, %adjustment
for aa1=1:a1,
x4(aa1,ab2,1) = x3(aa1,aa2,1);
x4(aa1,ab2,2) = x3(aa1,aa2,2);
x4(aa1,ab2,3) = x3(aa1,aa2,3);
end
ab2 = ab2 + 1;
end
%lower side
x4 = uint8(x4);
image_size = size(x4);
a1 = image_size(1,1);
a2 = image_size(1,2);
fire_r = 0;
for aa1=a1:-1:1,
for aa2=1:a2,
%if (((x4(aa1,aa2,1) >= 127) && (x4(aa1,aa2,1) <= 178))...
% && ((x4(aa1,aa2,2) >= 82) && (x4(aa1,aa2,2) <= 140))...
% && ((x4(aa1,aa2,3) >= 70) && (x4(aa1,aa2,3) <= 91)))
%track white
if (((x4(aa1,aa2,1) >= 0) && (x4(aa1,aa2,1) <= 240))...
&& ((x4(aa1,aa2,2) >= 0) && (x4(aa1,aa2,2) <= 240))...
&& ((x4(aa1,aa2,3) >= 0) && (x4(aa1,aa2,3) <= 240)))
fire_r = aa1;
break;
end
end
if fire_r ~= 0
break;
end
end
if fire_r == 0
fire_r = a1;
end
x5 = zeros(fire_r,a2,3);
ab1 = 1;
for aa1=1:fire_r, %adjustment
for aa2=1:a2,
x5(ab1,aa2,1) = x4(aa1,aa2,1);
x5(ab1,aa2,2) = x4(aa1,aa2,2);
x5(ab1,aa2,3) = x4(aa1,aa2,3);
end
ab1 = ab1 + 1;
end
%figure, imshow(x_orig);
x5 = uint8(x5);
  1 Comment
Image Analyst
Image Analyst on 6 Feb 2012
I don't have time to do private consulting on this. You can check my File Exchange for color segmentation demos. If you have a specific problem, such as an error message, then post it and someone will help you. But I don't have the time to spend hours adapting someone's code to your specific image, especially code with virtually no comments and confusing variable names. Sorry.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!