Page 1 of 1

Given is a greyscale 8 bit input image in the form of a pixel array (a list of pixel rows, with each row represented aga

Posted: Thu May 26, 2022 9:05 am
by answerhappygod
Given Is A Greyscale 8 Bit Input Image In The Form Of A Pixel Array A List Of Pixel Rows With Each Row Represented Aga 1
Given Is A Greyscale 8 Bit Input Image In The Form Of A Pixel Array A List Of Pixel Rows With Each Row Represented Aga 1 (80.33 KiB) Viewed 11 times
Given is a greyscale 8 bit input image in the form of a pixel array (a list of pixel rows, with each row represented again as a list). Every pixel contains an integer value between 0 and 255. Write a Python3 function 'computeVerticalEdgesSobelAbsolute(pixel_array, image_width, image_height)' which computes and returns an image of the vertical edges. The edge image has to use the 3x3 Sobel kernel for the gradient in x direction. Since the result can be positive or negative, for every pixel of the result the absolute value of the result has to be computed additionally (i.e. we treat positive and negative gradients the same). The resulting image has to contain float values. Border handling: Note that when applying the 3x3 Sobel kernel, the filtering procedure has to access pixels that are outside the input image. For this function simply ignore the 1 pixel boundary of the input image. We referred to this case as Borderlgnore in the lecture. We set the output pixels at the outer boundary to zero. You may assume that the Python3 function 'createInitialized Greyscale PixelArray(image_width, image_height)' is available, which creates an empty greyscale array (values 0) as a list of lists of integers. (Please use the skeleton Python code to see the effect of this edge detection code on actual images!) For example: Test Result image_width = 6 image_height = 5 pixel_array = [[30, 70, 20, 30, 20, 30], 0.000 0.000 0.000 0.000 0.000 0.000 0.000 12.500 7.500 5.000 3.750 0.000 0.000 7.500 0.000 0.000 2.500 0.000 0.000 6.250 6.250 2.500 7.500 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [0, 40, 60, 10, 40, 40], [30, 10, 20, 50, 20, 201, [10, 60, 30, 10, 50, 20], [40, 40, 60, 50, 0, 0] ] horizontal_edges = computeVertical Edges SobelAbsolute (pixel_array, image_width, image_height) printPixelArray (horizontal_edges) image_width=6 image_height = 5 pixel_array = [ [0, 0, 0, 0, 0, 0], 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.250 0.125 0.125 0.250 0.000 0.000 0.250 0.250 0.250 0.250 0.000 0.000 0.250 0.125 0.125 0.250 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0] ] horizontal_edges = computeVertical Edges SobelAbsolute (pixel_array, image_width, image_height) printPixelArray (horizontal_edges)