function [u0_SGL_BGL_bin u0_SGL u0_BGL] = im2bwSGLBGL(u0, u_rough_bin, thr_alpha, prior)
% 121120: Reza
% SGL/BGL binarization method: A binarization method based on SGL and BGL. It has a parameter, thr_alpha.
% u0: input document image
% u_rough_bin: A rough binarization of u0
% thr_alpha: alpha parameter of SGL/BGL method
% Version 0.9 (121120).

%
[xm ym zm]= size(u0);
%
u0_gray = universal_color_to_gray_converter(u0);
% figure, imshow(u0_gray)

% SGL
u0_SGL = my_compute_SGL_grid_based_rough_bin(u0, u_rough_bin, prior);
% figure, imshow([u0_gray, u0_SGL])

% BGL
u0_BGL = my_compute_BGL_grid_based_rough_bin(u0, u_rough_bin, prior);
% figure, imshow([u0_gray, u0_BGL])

% 
% thr_alpha = 0.15;
u0_THR = u0_BGL - thr_alpha * (1 - u0_SGL);
u0_SGL_BGL_bin = u0_gray > u0_THR;
% figure, imshow([u0_SGL_BGL_bin])


end