def get_mean_pore_size(img, nx):
    """
    Finds the mean pore diameter of the domain

    Parameters:
    ----------
    :param np.ndarray img:
        binary image array of domain
    :param int nx:
        number of pixels in x direction of fluid domain

    Returns
    -------
    :return: Model domain mean pore size
    """
    pores = []
    for line in img:
        pore = 0
        previous_value = True
        for value in line:
            if value and previous_value:
                pass

            elif value and not previous_value:
                if pore > nx * 0.9:
                    pore = 0
                else:
                    pores.append(pore)

            elif not value and previous_value:
                pore = 1

            elif not value and not previous_value:
                pore += 1

            previous_value = value

    mean_pore_size = sum(pores) / float(len(pores))
    return mean_pore_size