%
%img--image file
%k--   1-red, 2-green 3-blue.
%begin_v
%end_v   the range value of the color.
%Example:
%one_bin_vector_of_image('Sunset.jpg',1,0,31)


function [result]=one_bin_vector_of_image(img,k,begin_v,end_v)
data=double(imread(img));
a=size(data);
result=zeros(1,3);
for i=1:1:a(1)
    for j=1:1:a(2)
        if (data(i,j,k)>= begin_v & data(i,j,k) <= end_v)
            result(1)=result(1)+i;%adding the coordinates of y
            result(2)=result(2)+j;%adding the coordinates of x
            result(3)=result(3)+1;
        end
    end
end
if result(3)>0
    result(1)=result(1)/result(3);  %compute the mean value y
    result(2)=result(2)/result(3);  %compute the mean value x
end
