Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Fattening. Given a black and white 1 bit image (pixels are either 0 or 1) of

ID: 3639252 • Letter: 3

Question

3. Fattening. Given a black and white 1 bit image (pixels are either 0 or 1) of size wxh (e.g. 6x5), give an algorithm that fattens the drawing by setting to 1 all pixels who have at least one immediate neighbor that is 1. Hint: the algorithm traverses the image and, for each pixel, it checks whether one of its immediate neighbors is 1. If so, it sets the current pixel to 1. Immediate neighbors were defined in labs and lecture. The algorithm is similar to the 2-D convolution algorithm covered in class.
a. What is the output of the algorithm on the following image?
b. Give a brief step by step description of the algorithm.
c. Give a pseudocode description of the algorithm.
d. What is the algorithm running time? Explain.
0 1 1 1 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
0 0 0 0 0
Input image






Output image





If you know any question betwee a~d please help me.

Explanation / Answer

void SeedFill_1(int x, int y, COLORREF fill_color) { if( fill_color != GetPixel(x,y) ) { // sample pixel color SeedFill_1(x,y,fill_color); SeedFill_1(x-1,y,fill_color); SeedFill_1(x+1,y,fill_color); SeedFill_1(x,y-1,fill_color); SeedFill_1(x,y+1,fill_color); } } void SeedFill_2(int x, int y, COLORREF fill_color, COLORREF border_color) { if( border_color != GetPixel(x,y) ) { // sample pixel color SeedFill_2(x,y,fill_color,border_color); SeedFill_2(x-1,y,fill_color,border_color); SeedFill_2(x+1,y,fill_color,border_color); SeedFill_2(x,y-1,fill_color,border_color); SeedFill_2(x,y+1,fill_color,border_color); } } 1. Wrote QuickFill function based on what I could remember about scan line filling. 2. Replaced stack array with two singly linked lists. 3. Modified PopLine function, so that lines would be removed based on line number. 4. Added SearchLeft, SearchRight, ScanLeft, ScanRight functions; in order to allow for optimization of searching and scanning. 5. Added the PushOpposite function, which reverse splits lines, in order to reduce the number of lines revisited. This required that the list be changed to a doubly linked list and that the list be x-sorted. The reason behind this function was to eliminate all line revisits, but instead it just reduced the number of visits (at a cost). 6. Optimization of all of the above.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote