Highlights
1 Introduction to edge detection An image consists of pixels, where each pixel is typically represented by three values corresponding to three channels: red, green, and blue. Detecting edges in an image is a frequently employed effect (see Figure 1) in many applications of image processing, machine vision, computer vision, etc
There are multiple ways to detect edges in an image. For edge detection, the input image is typically converted to grayscale. An 8-bit grayscale image represents a pixel using one value (between 0 and 255). The output image can then be obtained by applying a simple technique on all the pixels of the input image. Figure 2 illustrates this technique to detect edges in an image. The mask is used to show large differences in pixel values. If a pixel’s neighboring pixels differ strongly in intensity, its updated value will appear white, otherwise black.
2 Tasks to complete This section describes the tasks constituting the edge detection program. In order to complete this assignment, you need to complete tasks 3–5 as per the following instructions. In the edge detect assgn.py file: 1. Read the input image file and convert it to an 8-bit grayscale format. In this format, each pixel is represented using an integer in the range [0, 256).
2. Add dummy pixels with a value of 0 along the image boundary, so that the 3x3 mask does not fall outside the actual image. The above tasks are already implemented in the function read coloring() in the helper functions.py file given to you.
The function returns a list of lists representing the pixel values. Let us name this 2D list pixel values. 3. Using list comprehension, create a list of lists to store the updated pixel information. Let us name these new pixel values.
The length of the list is numb rows and the length of each sublist is numb cold. Initialize all the values to 0. 4. Represent the values comprising the 3x3 image mask using a tuple of tuples. Let us name this 2D tuple mask
. You can use the values in Mask 1 or Mask 2. 5. Use mask to calculate a new value for every pixel in the image, excluding the dummy pixels. Since pixel values is a 2D data structure, use a 3 nested for loop to iterate through every pixel.
For each pixel, the following are the tasks that you have to implement: (a) Call a function get slice 2d list() (to be implemented by you), which takes as input the pixel values, the position of the pixel being calculated, and returns the 3x3 patch of surrounding pixels as a list of lists. For example, when updating the pixel shown in Figure 2, calling this function from within the nested for loop should return neighbor pixels = [[7, 5, 4], [3, 5, 3], [2, 1, 7]]. Use list slicing on pixel values to extract the required neighboring pixels.
Use list comprehension to create the 2D list neighbor pixels. (b) Call a function to flatten() (to be implemented by you), which takes as input a 2D list or a 2D tuple, and returns a 1D list. For example, when this function is given [[7, 5, 4], [3, 5, 3], [2, 1, 7]] as input, it should return [7, 5, 4, 3, 5, 3, 2, 1, 7]. When it is given ((-1, -1, -1), (-1, 8, -1), (-1, -1, -1)), it returns [-1, -1, -1, -1, 8, -1, -1, -1, -1]. Using this function, flatten neighbor pixels and mask.
Use list comprehension in the flatten() function to create a 1D list from the 2D list. (c) Apply the 1D list containing the mask values on the 1D list containing the neighborhood pixels using the map() function and a lambda. This lambda should multiply the corresponding elements of the two flattened lists.
This DV1614 - Python Assignment has been solved by our Python Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment Experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.