def ght_alternative (img, template, indices):
    """
    Alternative implementation of the general hough transform, which uses iteration over
    indices rather than broadcasting rules like `ght`.
    
    It is therefore considerably slower, especially for large, multi-dimensional arrays.
    The only application are cases, where the hough transform should only be computed for
    a small number of points (=template centers) in the image. In this case the indices
    of interest can be provided as a list.
    
    Parameters
    ----------
    img : array_like
        The image in which to search for the structure.
    template : array_like
        A boolean array containing the structure to search for.
    indices : sequences
        A sequence of image indices at which to compute the hough transform.
    
    Returns
    -------
    hough_transform : ndarray
        The general hough transformation image.
    """
    # cast template to bool and img to numpy array
    img = numpy.asarray(img)
    template = numpy.asarray(template).astype(numpy.bool)
    
    # check supplied parameters
    if img.ndim != template.ndim:
        raise AttributeError('The supplied image and template must be of the same dimensionality.')
    if not numpy.all(numpy.greater_equal(img.shape, template.shape)):
        raise AttributeError('The supplied template is bigger than the image. This setting makes no sense for a hough transform.')
    
    # pad the original image
    img_padded = pad(img, footprint=template, mode='constant')
    
    # prepare the hough image
    if numpy.bool == img.dtype:
        img_hough = numpy.zeros(img.shape, numpy.int32)
    else:
        img_hough = numpy.zeros(img.shape, img.dtype)
        
    # iterate over the pixels, apply the template center to each of these and save the sum into the hough image
    for idx_hough in indices:
        idx_hough = tuple(idx_hough)
        slices_img_padded = [slice(idx_hough[i], None) for i in range(img_hough.ndim)]
        img_hough[idx_hough] = sum(img_padded[slices_img_padded][template])     
        
    return img_hough
def ght_alternative ( img , template , indices ) : img = numpy . asarray ( img ) template = numpy . asarray ( template ) . astype ( numpy . bool ) if img . ndim != template . ndim : raise AttributeError ( 'The supplied image and template must be of the same dimensionality.' ) if not numpy . all ( numpy . greater_equal ( img . shape , template . shape ) ) : raise AttributeError ( 'The supplied template is bigger than the image. This setting makes no sense for a hough transform.' ) img_padded = pad ( img , footprint = template , mode = 'constant' ) if numpy . bool == img . dtype : img_hough = numpy . zeros ( img . shape , numpy . int32 ) else : img_hough = numpy . zeros ( img . shape , img . dtype ) for idx_hough in indices : idx_hough = tuple ( idx_hough ) slices_img_padded = [ slice ( idx_hough [ i ] , None ) for i in range ( img_hough . ndim ) ] img_hough [ idx_hough ] = sum ( img_padded [ slices_img_padded ] [ template ] ) return img_hough
Alternative implementation of the general hough transform, which uses iteration over
    indices rather than broadcasting rules like `ght`.
    
    It is therefore considerably slower, especially for large, multi-dimensional arrays.
    The only application are cases, where the hough transform should only be computed for
    a small number of points (=template centers) in the image. In this case the indices
    of interest can be provided as a list.
    
    Parameters
    ----------
    img : array_like
        The image in which to search for the structure.
    template : array_like
        A boolean array containing the structure to search for.
    indices : sequences
        A sequence of image indices at which to compute the hough transform.
    
    Returns
    -------
    hough_transform : ndarray
        The general hough transformation image.