function [props, outBW] = PS_roiExtraction_global(temp1,M,A)
%***********************************************************************
% This function convert grayscale image to binary image and show ROIs > 10
% pixels. Input variable: a grayscale image. Output variable: a black and
% white image with ROIs >10 pixels in black.
%**************************************************************************
% Modified by Kaichang CHENG in Mar. 3, 2019.
% 1.Change the threshhold of function bwareaopen into 8.
%**************************************************************************
% Modified by Kaichang CHENG in Mar. 27, 2019.
% 1.Change the threshhold of function bwareaopen into 10.
%**************************************************************************
% Modified by Kaichang CHENG in Apr. 22, 2019.
% 1. Use the Otsu's method to extract ROIs based on remove the uneven 
% illumnination.
%**************************************************************************
%%
tempImage=temp1;
%graythresh(tempImage)
tempBinary = imbinarize(tempImage);%0.53
tempBinary = imcomplement(tempBinary);
tempBW1 = imfill(tempBinary,'holes');
% figure,imshow(tempBW1)
se = strel('disk',M);
closeBW = imclose(tempBW1,se);
outBW = bwareaopen(closeBW, A);
%figure,imshow(outBW)
props = regionprops(outBW, 'boundingbox');
end