function [BW,maskedRGBImage_2] = createMask(RGB)
Original_Picture = RGB;
channel1Min = 149.000;
channel1Max = 255.000;
channel2Min = 140.000;
channel2Max = 255.000;
channel3Min = 140.000;
channel3Max = 255.000;
BW = (Original_Picture(:,:,1) >= channel1Min ) & (Original_Picture(:,:,1) <= channel1Max) & ...
(Original_Picture(:,:,2) >= channel2Min ) & (Original_Picture(:,:,2) <= channel2Max) & ...
(Original_Picture(:,:,3) >= channel3Min ) & (Original_Picture(:,:,3) <= channel3Max);
maskedRGBImage_2 = RGB;
maskedRGBImage_2(repmat(~BW,[1 1 3])) = 0;
Image_Size=size(maskedRGBImage_2);
x = Image_Size(2);
y = Image_Size(1);
s = zeros(1,350);
top_left_x = 0;
top_left_y = 0;
for y = 1:3168;
for x = 1:4752;
Test_pixel = maskedRGBImage_2(y,x);
if Test_pixel == 255
for k = x:(x+349);
g = maskedRGBImage_2(y, k);
f = k - x + 1;
s(1,f) = g;
g_sum = nnz(s);
if g_sum > 330;
top_left_x = x;
top_left_y = y;
return
end
end
end
end
end
Original_Picture = imcrop(rgb2hsv(RGB),[x y (x+350)-x (y+450)-y]);
channel1Min = 0.063;
channel1Max = 0.096;
channel2Min = 0.111;
channel2Max = 0.131;
channel3Min = 0.612;
channel3Max = 0.647;
BW = (Original_Picture(:,:,1) >= channel1Min ) & (Original_Picture(:,:,1) <= channel1Max) & ...
(Original_Picture(:,:,2) >= channel2Min ) & (Original_Picture(:,:,2) <= channel2Max) & ...
(Original_Picture(:,:,3) >= channel3Min ) & (Original_Picture(:,:,3) <= channel3Max);
BW = ~BW;
maskedRGBImage_2 = RGB;
maskedRGBImage_2(repmat(~BW,[1 1 3])) = 0;