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
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}|];
Step by step
Solved in 3 steps