def edge_detect(image, size):
    """
    Applies a Sobel filter to the given image.
    :param image: An image as a list of (R,G,B) values
    :param size: The size of the image as a tuple (width, height)
    :return: An array of the Sobel gradient value of each image pixel
    This value roughly corresponds to how much of an "edge" a pixel is.
    """
    # TODO get edge data for boundaries
    width, height = size
    edge_data = [0] * len(image)
    gray_scale_img = list(map(luma, image))
    for y in range(1, height - 1):
        for x in range(1, width - 1):
            idx = coords_to_index((x, y), width)

            a, b, c = gray_scale_img[idx - 1 - width: idx + 2 - width]
            d, e, f = gray_scale_img[idx - 1: idx + 2]
            g, h, i = gray_scale_img[idx - 1 + width: idx + 2 + width]

            g_x = -a - 2 * d - d + c + 2 * f + i
            g_y = -a - 2 * b - c + g + 2 * h + i

            g = sqrt(g_x * g_x + g_y * g_y)
            edge_data[idx] = g

            if idx % 200000 == 0:
                logger.info("Edge detection done for %d / %d pixels... (%2.2f%%)" %
                            (idx, width * height, 100 * idx / float(width * height)))
    return edge_data
Applies a Sobel filter to the given image.
    :param image: An image as a list of (R,G,B) values
    :param size: The size of the image as a tuple (width, height)
    :return: An array of the Sobel gradient value of each image pixel
    This value roughly corresponds to how much of an "edge" a pixel is.