function Centroid = Path_find_yellow(im);
% % camera1 =imread('http://172.16.6.1/axis-cgi/jpg/image.cgi?resolution=800X600');
% % camera2 =imread('http://172.16.6.2/axis-cgi/jpg/image.cgi?resolution=800X600');
% % camera3 =imread('http://172.16.6.3/axis-cgi/jpg/image.cgi?resolution=800X600');
% % camera4 = zeros(size(camera1));
% % camera5 = zeros(size(camera1));
% % camera6 = zeros(size(camera1));
% % 
% % camera6 = camera6(1:560,1:90,1:end);
% % camera3 = camera3(1:560,1:472,1:end);
% % camera4 = camera4(110:end,1:455,1:end);
% % camera1 = camera1(1:560,18:end,1:end);
% % camera5 = camera5(1:560,661:end,1:end);
% % camera2 = camera2(110:end,1:end,1:end);
% % 
% % camera_full = [camera3,camera1;camera4,camera2];%
% % camera_full=imresize(camera_full,.5);
% % rgb_img = imread('http://172.16.6.1/axis-cgi/jpg/image.cgi?resolution=800X600');
% % im = camera_full;
% % clear all
% % close all
% % clc
%% Read img
%   camera1 = 'http://172.16.6.2/axis-cgi/jpg/image.cgi?resolution=800X600';  
%   im = imread(camera1);
%  pause
% im = imread('yellow.jpg');
% load('im.mat')
%im = rgb_img;
 
% Find Black crop them!
imblack =0.5*im(:,:,1)+0.5*im(:,:,2)+0.5*im(:,:,3);
black = im2bw(imblack,0.4);
black = bwareaopen(black,30);
figure(1),imshow(black)
Real_Area=zeros(2,1);
Real_Centroid =zeros(2);
stats_black = regionprops(black,'BoundingBox');
j=1;
 
%% Find Yellow Centroid
 for i = 1: numel(stats_black)
    % Find yellow using RGB matrix
    imfid = imcrop(im,stats_black(i).BoundingBox);
    if(length(imfid)>100)
    else
%     imshow(imfid);
%     pause 
        imyellow = 0.7*imfid(:,:,1) + 0.5*imfid(:,:,2) - 0.4*imfid(:,:,3);
        yellow = im2bw(imyellow,0.5);
        yellow = bwareaopen(yellow,5);
        stats_yellow = regionprops(yellow,'Area','Centroid');
        for(x = 1:length(stats_yellow))
            if(stats_yellow(x).Area>20)
                Real_Area (j)= stats_yellow(x).Area;
                Real_Centroid (j,:)= stats_black(i).BoundingBox(1:2)+stats_yellow(x).Centroid;          
                j=j+1;
            end
        end
    end
 end
 %% Post process
 x = find(Real_Centroid == 0);
 Real_Centroid(x) = [];
 %
 if(Real_Area(1)>Real_Area(2))
 else %swap
     temp = Real_Centroid(2,:);
     Real_Centroid(2,:) = Real_Centroid(1,:);
     Real_Centroid(1,:) = temp;
 end
 
 Centroid = Real_Centroid;
%  %% Grab only BLACK pixels
% empty_intensity = 0*rgb2gray(im); % create an empty intensity matrix
% black_indices = find(50 < rgb_img(:,:,1) < 60 & 50 < rgb_img(:,:,2) < 60 & 50 <rgb_img(:,:,3) < 60);
% empty_intensity(black_indices) = 255; % operate on matrix like column vector
% bw = im2bw(empty_intensity,0.5); % threshold image to produce pure black/white
% imshow(bw); % show result
% 
% %% Remove noise... not necessary for this image, but might be later
% % remove all object containing fewer than 30 pixels
%  sbw = bwareaopen(bw,15);
% % 
% % % fill a gap in the pen's cap
%  se = strel('disk',2);
%  bw = imclose(sbw,se);
% % 
% % % fill any holes, so that regionprops can be used to estimate
% % % the area enclosed by each of the boundaries
%  bw = imfill(bw,'holes');
% % 
% % imshow(bw)
% 
% %% Find boundaries so that we can get region properties
% [B,L] = bwboundaries(bw,'noholes');
% 
% % Display the label matrix and draw each boundary
% % %imshow(label2rgb(L, @jet, [.5 .5 .5])) 
% % hold on
% % for k = 1:length(B)
% %   boundary = B{k};
% %   plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
% % end
% 
% % %% Find the centroid position
%  s  = regionprops(bw, 'centroid','orientation','MajorAxisLength');
%  centroids = cat(1, s.Centroid);
% % 
% % stats_black = regionprops(bw,'BoundingBox');
% imcrop(im,[round(centroids(1))+30,round(centroids(2))+30,60,60]);
% figure
% imshow(imcrop)