hi everyone,
i need help in explaining this code, i know it is vertical seam removal but just need more details to explain what is really happening:::::
i need help in explaining this code, i know it is vertical seam removal but just need more details to explain what is really happening:::::
def delete_vertical_seam (img, path): """ Deletes the pixels in a vertical path from img @img: an input img @path: pixels to delete in a vertical path """ print_fn( "Deleting Vertical Seam..." ) #raise Exception img_width, img_height = img.size i = Image.new(img.mode, (img_width-1, img_height)) input = img.load() output = i.load() path_set = set(path) seen_set = set() for x in range(img_width): for y in range(img_height): if (x,y) not in path_set and y not in seen_set: output[x,y] = input[x,y] elif (x,y) in path_set: seen_set.add(y) else: output[x-1,y] = input[x,y] print_fn( "Deletion Complete." ) return i def add_vertical_seam(img, path): """ Adds the pixels in a vertical path from img @img: an input img @path: pixels to delete in a vertical path """ print_fn( "Adding Vertical Seam..." ) img_width, img_height = img.size i = Image.new(img.mode, (img_width + 1, img_height) ) input = img.load() output = i.load() path_set = set(path) seen_set = set() for x in range(img_width): for y in range(img_height): if (x,y) not in path_set and y not in seen_set: output[x,y] = input[x,y] elif (x,y) in path_set and y not in seen_set: output[x,y] = input[x,y] seen_set.add( y ) if x < img_width -2: output[x+1,y] = vector_avg(input[x,y], input[x+1,y]) else: output[x+1,y] = vector_avg(input[x,y], input[x-1,y]) else: output[x+1,y] = input[x,y] print_fn( "Addition Complete." ) return i