creen You are given the type  type pixel ={ r : int ; g : int ; b : int };; representing a pixel and its intensity of red, green and blue, as integers between 0 and 255. a. Write a function brightness : int -> pixel array array -> pixel array array = that increases/decreases all integers in all pixels in the input pixel array array by the provided integer. The resulting integers should not go below 0 or above 255. b. Write a function blur : pixel array array -> pixel array array = that blurs the input pixel array array. Pixels on the border are unchanged, all other pixels colors however are recomputed. The new 3 value is 60% of the original value + 5% of every neighboring pixel’s original value (out of 8). Round down at the very end.  heres the output: # let generate_screen rows columns seed = Random . init seed ; Array . make_matrix rows columns 0 | > Array . map ( Array . map (fun x - >{ r = Random . int 255; g = Random . int

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Screen

You are given the type

 type pixel ={ r : int ; g : int ; b : int };;

representing a pixel and its intensity of red, green and blue, as integers between 0 and 255.

a. Write a function brightness : int -> pixel array array -> pixel array array = that increases/decreases all integers in all pixels in the input pixel array array by the provided integer. The resulting integers should not go below 0 or above 255.

b. Write a function blur : pixel array array -> pixel array array = that blurs the input pixel array array. Pixels on the border are unchanged, all other pixels colors however are recomputed. The new 3 value is 60% of the original value + 5% of every neighboring pixel’s original value (out of 8). Round down at the very end. 

heres the output:

# let generate_screen rows columns seed = Random . init
seed ; Array . make_matrix rows columns 0 | > Array . map
( Array . map (fun x - >{ r = Random . int 255; g = Random . int
255; b = Random . int 255}) ) ;;
val generate_screen : int -> int -> int -> pixel array
array = <fun >
 # let screen = generate_screen 6 4 2023 ;;
val screen : pixel array array =
 [|[|{ r = 250; g = 73; b = 96}; { r = 165; g = 100; b
= 146};
 { r = 194; g = 51; b = 245}; { r = 45; g = 54; b =
72}|];
[|{ r = 235; g = 108; b = 6}; { r = 214; g = 228; b
= 220};
{ r = 28; g = 176; b = 125}; { r = 131; g = 188; b
= 14}|];
 [|{ r = 56; g = 40; b = 166}; { r = 36; g = 195; b =
48};
 { r = 245; g = 20; b = 86}; { r = 212; g = 225; b
= 144}|];
 [|{ r = 17; g = 242; b = 179}; { r = 73; g = 92; b =
157};
 { r = 25; g = 49; b = 70}; { r = 218; g = 233; b =
165}|];
[|{ r = 224; g = 84; b = 134}; { r = 78; g = 231; b
= 254};
{ r = 25; g = 10; b = 140}; { r = 56; g = 139; b =
5}|];
[|{ r = 237; g = 85; b = 142}; { r = 202; g = 163; b
= 161};
 { r = 82; g = 191; b = 183}; { r = 245; g = 79; b
= 234}|]|]
 # brightness (100) screen ;;
- : pixel array array =
[|[|{ r = 255; g = 173; b = 196}; { r = 255; g = 200; b
= 246};
{ r = 255; g = 151; b = 255}; { r = 145; g = 154; b
= 172}|];
 [|{ r = 255; g = 208; b = 106}; { r = 255; g = 255; b
= 255};
 { r = 128; g = 255; b = 225}; { r = 231; g = 255; b
= 114}|]; 

23
24
25
26
27
28
29
30
36
37
38
39
40
41
42
32
33 [[{r
34
35
43
[1 {r
48
50
= 148};
{r 255; g =
= 244}|];
[{r
=
{r
=
= 255);
{r = 125; g =
= 255}|];
[{r = 255; g =
255};
{r = 125; g =
105} ];
[{r = 255; g =
=
255};
31 #brightness (-100) screen ;;
pixel array array =
=
=
255}]]
{r =
[1 {r =
156; g = 140; b = 255}; {r = 136; g = 255; b
120; b 186}; {r
255; g =
255; b
255}; {r = 173; g =
192; b
170}; {r = 255; g = 255; b
234}; {r = 178; g = 255; b
240}; {r =
156; g =
239; b
242}; {r = 255; g =
255; b
255}; {r = 255; g = 179; b
[1 {r
=
[1 {r
117; g =
{r =
=
=
255; b =
149; b =
120};
{r
= 0; g = 76; b = 25}; {r = 31; g = 88; b =
0}|];
[1 r = 0; g
145; g
{r = 112; g = 125; b= 44}|];
=
[1 {r
{r
184; b =
182; g 255; b =
110; b =
45 # blur screen
46
47 [1 [1 {r
185; b =
=
150; g = 0; b = 0}; {r = 65; g = 0; b = 46};
94; g = 0; b = 145}; {r = 0; g 0; b=0}];
135; g = 8; b = 0}; {r = 114; g = 128; b =
0; b = 66}; {r = 0; g = 95; b = 0}; {r
= 0; b = 0};
0; g 142; b = 79}; (r = 0; g
0; b = 0};
0; g
118; g = 133; b = 65}|];
124; g = 0; b = 34}; {r = 0; g = 131; b
61};
{r = 0; g = 91; b = 83}; {r
134}|]]
=
154};
{r =
0; g = 0; b = 40}; (r = 0; g = 39; b=0} [];
= 137; g = 0; b = 42}; {r
102; g = 63; b =
145; g = 0; b =
=
=
158; b = 123}; {r
= 0; b = 57};
pixel array array =
= 250; g = 73; b= 96}; {r
146};
{r 194; g = 51; b=245}; {r
72}|];
[1 {r = 235; g = 108; b = 6}; {r = 188; g = 174; b =
177};
{r = 78; g =
131; 8 = 188; b =
= 165; g =
=
=
=
100; b =
45; g = 54; b =
Transcribed Image Text:23 24 25 26 27 28 29 30 36 37 38 39 40 41 42 32 33 [[{r 34 35 43 [1 {r 48 50 = 148}; {r 255; g = = 244}|]; [{r = {r = = 255); {r = 125; g = = 255}|]; [{r = 255; g = 255}; {r = 125; g = 105} ]; [{r = 255; g = = 255}; 31 #brightness (-100) screen ;; pixel array array = = = 255}]] {r = [1 {r = 156; g = 140; b = 255}; {r = 136; g = 255; b 120; b 186}; {r 255; g = 255; b 255}; {r = 173; g = 192; b 170}; {r = 255; g = 255; b 234}; {r = 178; g = 255; b 240}; {r = 156; g = 239; b 242}; {r = 255; g = 255; b 255}; {r = 255; g = 179; b [1 {r = [1 {r 117; g = {r = = = 255; b = 149; b = 120}; {r = 0; g = 76; b = 25}; {r = 31; g = 88; b = 0}|]; [1 r = 0; g 145; g {r = 112; g = 125; b= 44}|]; = [1 {r {r 184; b = 182; g 255; b = 110; b = 45 # blur screen 46 47 [1 [1 {r 185; b = = 150; g = 0; b = 0}; {r = 65; g = 0; b = 46}; 94; g = 0; b = 145}; {r = 0; g 0; b=0}]; 135; g = 8; b = 0}; {r = 114; g = 128; b = 0; b = 66}; {r = 0; g = 95; b = 0}; {r = 0; b = 0}; 0; g 142; b = 79}; (r = 0; g 0; b = 0}; 0; g 118; g = 133; b = 65}|]; 124; g = 0; b = 34}; {r = 0; g = 131; b 61}; {r = 0; g = 91; b = 83}; {r 134}|]] = 154}; {r = 0; g = 0; b = 40}; (r = 0; g = 39; b=0} []; = 137; g = 0; b = 42}; {r 102; g = 63; b = 145; g = 0; b = = = 158; b = 123}; {r = 0; b = 57}; pixel array array = = 250; g = 73; b= 96}; {r 146}; {r 194; g = 51; b=245}; {r 72}|]; [1 {r = 235; g = 108; b = 6}; {r = 188; g = 174; b = 177}; {r = 78; g = 131; 8 = 188; b = = 165; g = = = = 100; b = 45; g = 54; b =
51
52
53
54
55
56
57
58
14}|];
[{r = 56; g = 40; b = 166}; {r = 66; g
79};
{r = 193; g = 81; b =
144} ];
[{r = 17; g = 242; b =
148};
{r = 62; g = 86; b =
165}];
= 224; g = 84; b = 134}; {r = 91; g = 184; b =
63; g = 64; b= 145}; {r = 56; g = 139; b =
237; g
142}; {r 202; g = 163; b =
161};
{r = 82; g = 191; b = 183}; {r = 245; g = 79; b =
234}]]
[1 {r
210};
{r=
5}1];
[1 {r
= 85; b =
98}; {r =
= 164; b =
91}; {r =
212; g = 225; b =
179}; {r = 79; g =
=98; b =
218; g = 233; b =
Transcribed Image Text:51 52 53 54 55 56 57 58 14}|]; [{r = 56; g = 40; b = 166}; {r = 66; g 79}; {r = 193; g = 81; b = 144} ]; [{r = 17; g = 242; b = 148}; {r = 62; g = 86; b = 165}]; = 224; g = 84; b = 134}; {r = 91; g = 184; b = 63; g = 64; b= 145}; {r = 56; g = 139; b = 237; g 142}; {r 202; g = 163; b = 161}; {r = 82; g = 191; b = 183}; {r = 245; g = 79; b = 234}]] [1 {r 210}; {r= 5}1]; [1 {r = 85; b = 98}; {r = = 164; b = 91}; {r = 212; g = 225; b = 179}; {r = 79; g = =98; b = 218; g = 233; b =
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education