code: def trapezoid_membership(bin_center, bin_width, smoothness):
      r"""Create a trapezium membership function for a fuzzy histogram bin.
      
      Parameters
      ----------
      bin_center : number
          The center of the bin of which to compute the membership function.
      bin_width : number
          The width of a single bin (all expected to be of equal width).
      smoothness : number, optional
          The smoothness of the function; determines the neighbourhood affected.
          See below and `fuzzy_histogram` for a more detailed explanation
          
      Returns
      -------
      trapezoid_membership : function
          A trapezoidal membership function centered on the bin.
      
      Notes
      -----
      For the trapezium function the smoothness factor can be between >0.0 and <0.5.
      Higher values are excepted, but then the function assumes the shape of the triangular
      membership function. A value of 0.0 would make the histogram behave like a crisp one.
      
      The trapezium membership function is defined as
      
      .. math::
      
          \mu_{trapez}(x) =
            \left\{
              \begin{array}{ll}
                0, & x<a, x>d\\
                \frac{x-a}{b-a}, & a\leq x\leq b \\
                1, & b<x<c\\
                \frac{d-x}{d-c}, & c\leq x\leq d\\
              \end{array}
            \right.
      
      where :math:`a` is the left lower border, :math:`b` the left upper border, :math:`c` the right upper border
      and :math:`d` the right lower border of the trapezium.
      
      A smoothness term of 0.1 makes the trapezium function reach by :math:`0.1 * bin\_width` into
      the areas of the adjunct bins, as can be observed in the following figure
      
      .. .. image:: images/trapezium_02.png
      
      "Trapezium functions (1)"
      
      where the bin width is 2 with centers at -2, 0 and 2.
      
      Increasing the smoothness term toward 0.5, the function starts to resemble the
      triangular membership function, which in fact it becomes for any :math:`smoothness >= 0.5`.
      The behavior can be observed in the following graph with :math:`smoothness=0.4` 
      
      .. .. image:: images/trapezium_01.png
      
      "Trapezium functions (2)"
      
      Lowering the smoothness toward 0.0, on the other hand, leads the trapezium function
      to behave more and more like a crisp histogram membership, which in fact it becomes
      at a smoothness of 0.0. The following figure, where the smoothness term is near zero,
      illustrates this behaviour
      
      .. .. image:: images/trapezium_03.png
      
      "Trapezium functions (3)"
      
      """
      # special case of high smoothness
      if smoothness < 1.0 / 10:
          raise AttributeError(
              "the triangular/trapezium membership functions supports only smoothnesses between 1/10 and 1/2."
          )
      if smoothness >= 0.5:
          return triangular_membership(
              bin_center, bin_width, smoothness
          )
  
      a = bin_center - (smoothness + 0.5) * bin_width
      b = bin_center - (0.5 - smoothness) * bin_width
      c = bin_center + (0.5 - smoothness) * bin_width
      d = bin_center + (smoothness + 0.5) * bin_width
  
      def fun(x):
          if x < a or x > d:
              return 0
          elif x <= b:
              return (x - a) / float(b - a)
          elif x <= c:
              return 1
          else:
              return (d - x) / float(d - c)
  
      return fun
  
file_path: medpy/medpy/features/histogram.py
imports: import math
  import scipy.stats
label_desc: Use image node_id 3 for calling a global function with example usage: trapezoid_membership(bin_center, bin_width, smoothness) and returns: fun, triangular_membership, int, unknown, int, unknown