You are given the type type pixel={r:int; g: int; b: int};; representing a pixel and the intensity of red, green and blue, as integers between 0 and 255. 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. 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 value is 60% of the original + 5% of every neighboring pixel (out of 8). Round down at the very end.

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

Ocaml, functional programming task.

You are given the type
₁ type pixel={r:int; g: int; b: int};;
representing a pixel and the intensity of red, green and blue, as integers between
0 and 255.
Write a function brightness: int -> pixel array array -> pixel
array array = <fun> 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.
Write a function blur: pixel array array -> pixel array array
= <fun> that blurs the input pixel array array. Pixels on the border
are unchanged, all other pixels colors however are recomputed. The new
value is 60% of the original + 5% of every neighboring pixel (out of 8).
Round down at the very end.
Transcribed Image Text:You are given the type ₁ type pixel={r:int; g: int; b: int};; representing a pixel and the intensity of red, green and blue, as integers between 0 and 255. Write a function brightness: int -> pixel array array -> pixel array array = <fun> 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. Write a function blur: pixel array array -> pixel array array = <fun> that blurs the input pixel array array. Pixels on the border are unchanged, all other pixels colors however are recomputed. The new value is 60% of the original + 5% of every neighboring pixel (out of 8). Round down at the very end.
#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})) ;;
2 val generate_screen: int -> int -> int -> pixel array
array = <fun>
3 # let screen-generate_screen 6 4 2023 ;;
4 val screen
pixel array array =
5
[I[{r = 250; g = 73; b = 96}; {r = 165; g = 100; b
= 146};
{r 194; g = 51; b = 245}; {r = 45; g =
72}1];
[1 {r = 235; g = 108; b = 6}; {r = 214; g =
= 220};
{r
= 14} ];
6
T
0
6
20
21
23
28; g 176; b= 125}; {r = 131; g = 188; b
[{r = 56; g 40; b=166}; {r = 36; g = 195; b
48};
{r
= 144} ];
#brightness (100) screen ;;
8 pixel array array =
[I[{r
245; g = 20; b = 86}; {r = 212; g = 225; b
[{r = 17; g = 242; b= 179}; {r = 73; g = 92; b =
157);
{r = 25; g = 49; b = 70}; {r = 218; g = 233; b =
165}|];
[1 {r = 224; g = 84; b = 134}; {r = 78; g = 231; b
= 254};
25; g = 10; b= 140}; {r = 56; g = 139; b =
{r
5} 1];
[{r=237; g = 85; b = 142}; {r = 202; g = 163; b
= 161};
{r = 82; g = 191; b = 183}; {r = 245; g = 79; b
= 234}1] 1]
54; b =
228; b
255; g = 173; b = 196}; {r = 255; g = 200; b
246};
{r
255; g =
151; b =
255); (r = 145; g 154; b
= 172} 1];
[{r = 255; g =
208; b =
106}; {r = 255; g =
255; b
= 255};
{r
128;
= 114} ];
[{r
156; g =
= 148};
{r
= 244} ];
g =
255;
g = 120; b =
255; b = 225}; {r = 231; g = 255; b
140; b=
255};
{r
136; g = 255; b
186); (r= 255; g = 255; b
=
Transcribed Image Text:#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})) ;; 2 val generate_screen: int -> int -> int -> pixel array array = <fun> 3 # let screen-generate_screen 6 4 2023 ;; 4 val screen pixel array array = 5 [I[{r = 250; g = 73; b = 96}; {r = 165; g = 100; b = 146}; {r 194; g = 51; b = 245}; {r = 45; g = 72}1]; [1 {r = 235; g = 108; b = 6}; {r = 214; g = = 220}; {r = 14} ]; 6 T 0 6 20 21 23 28; g 176; b= 125}; {r = 131; g = 188; b [{r = 56; g 40; b=166}; {r = 36; g = 195; b 48}; {r = 144} ]; #brightness (100) screen ;; 8 pixel array array = [I[{r 245; g = 20; b = 86}; {r = 212; g = 225; b [{r = 17; g = 242; b= 179}; {r = 73; g = 92; b = 157); {r = 25; g = 49; b = 70}; {r = 218; g = 233; b = 165}|]; [1 {r = 224; g = 84; b = 134}; {r = 78; g = 231; b = 254}; 25; g = 10; b= 140}; {r = 56; g = 139; b = {r 5} 1]; [{r=237; g = 85; b = 142}; {r = 202; g = 163; b = 161}; {r = 82; g = 191; b = 183}; {r = 245; g = 79; b = 234}1] 1] 54; b = 228; b 255; g = 173; b = 196}; {r = 255; g = 200; b 246}; {r 255; g = 151; b = 255); (r = 145; g 154; b = 172} 1]; [{r = 255; g = 208; b = 106}; {r = 255; g = 255; b = 255}; {r 128; = 114} ]; [{r 156; g = = 148}; {r = 244} ]; g = 255; g = 120; b = 255; b = 225}; {r = 231; g = 255; b 140; b= 255}; {r 136; g = 255; b 186); (r= 255; g = 255; b =
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
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.
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