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.
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
Related questions
Question
Ocaml, functional
![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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe748bbd7-046b-4ffe-8f1b-a210bc1b8b6f%2F0a31b0e3-c73a-44c9-9c54-a43f06af12f3%2Fhi0kx39_processed.png&w=3840&q=75)
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
=](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe748bbd7-046b-4ffe-8f1b-a210bc1b8b6f%2F0a31b0e3-c73a-44c9-9c54-a43f06af12f3%2Fn0j7fy_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education