<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_cylinder(im, r=None, axis=0):
 r""" Returns a cylindrical section of the image of specified radius. This is useful for making square images look like cylindrical cores such as those obtained from X-ray tomography. Parameters im : ND-array The image of the porous material. Can be any data type. r : scalr The radius of the cylinder to extract. If ``None`` is given then the default is the largest cylinder that can fit inside the specified plane. axis : scalar The axis along with the cylinder will be oriented. Returns ------- image : ND-array A copy of ``im`` with values outside the cylindrical area set to 0 or ``False``. """

    if r is None:
        a = list(im.shape)
        a.pop(axis)
        r = sp.floor(sp.amin(a) / 2)
    dim = [range(int(-s / 2), int(s / 2) + s % 2) for s in im.shape]
    inds = sp.meshgrid(*dim, indexing='ij')
    inds[axis] = inds[axis] * 0
    d = sp.sqrt(sp.sum(sp.square(inds), axis=0))
    mask = d < r
    im_temp = im*mask
    return im_temp