import math


def index_to_coords(index, width):
    """
    Converts an index in an array of pixels to an x, y coordinate given an image width.
    :param index: The index in the array
    :param width: The width of the image
    :return: (x,y) coordinate of the pixels specified by `index`
    """
    return index % width, math.floor(index / width)