Dithering is a technique for converting grayscale images to black-andwhite images (for printed media like newspapers). The classic dithering algorithm proceeds as follows. For every pixel in the...




Dithering is a technique for converting grayscale images to black-andwhite images (for printed media like newspapers). The classic dithering algorithm proceeds as follows. For every pixel in the image, going from top to bottom (“north to south”), and from left to right (“west to east”):


• “Round” the current pixel to black or white. (If it’s closer to black, make it black; if it’s closer to white, make it white.)


• This alteration to the current pixel has created “rounding error” x (in other words, we have added x > 0 “whiteness units” by making it white, or x <>


I assigned a dithering exercise in an introductory CS class, and I got, more or less, the code in Figure 3.19 from one student. This code is correct, but it is very repetitious. Reorganize this code so that it’s not so repetitive. In particular, rewrite lines 7–63 ensuring that each “distribute the error” line (9, 11, 12, and 13) appears only once if your solution.


Recall Definition 3.16: a proposition ϕ is in conjunctive normal form (CNF) if ϕ is the conjunction of one or more clauses, where each clause is the disjunction of one or more literals, and where a literal is an atomic proposition or its negation. Further, recall Definition 3.17: ϕ is in disjunctive normal form (DNF) if ϕ is the disjunction of one or more clauses, where each clause is the conjunction of one or more literals








May 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here