Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fp:lab07 [2022/04/20 14:51]
pdmatei
fp:lab07 [2022/05/03 17:25] (current)
pdmatei
Line 58: Line 58:
 </​code>​ </​code>​
  
-**7.8.** Write a function which inverts an image (values 0 become 255, 1 - 254, and so forth).+**7.6.** Write a function which inverts an image (values 0 become 255, 1 - 254, and so forth).
  
-**7.9.** Write a function which crops a given image, using two, two-dimensional coordinates:​ the lower-left point x and y, and the higher-right point x and y. An example is shown below:+**7.7.** Write a function which crops a given image, using two, two-dimensional coordinates:​ the higher-left point x and y, and the lower-right point x and y. An example is shown below:
 <code scala> <code scala>
 val img = List(List(0,​0,​1,​0,​0),​ List(0,​1,​0,​1,​0),​ List(0,​1,​1,​1,​0),​ List(1,​0,​0,​0,​1),​ List(1,​0,​0,​0,​1)) val img = List(List(0,​0,​1,​0,​0),​ List(0,​1,​0,​1,​0),​ List(0,​1,​1,​1,​0),​ List(1,​0,​0,​0,​1),​ List(1,​0,​0,​0,​1))
Line 66: Line 66:
       0 0 1 0 0       0 0 1 0 0
 *     0 1 0 1 0                                           1 0 1 *     0 1 0 1 0                                           1 0 1
-*     0 1 1 1 0     ​cropping from 1,1  to  ​3,2  yields: ​  1 1 1+*     0 1 1 1 0     ​cropping from 1,1  to  2,3  ​yields: ​  1 1 1
 *     1 0 0 0 1 *     1 0 0 0 1
 *     1 0 0 0 1 *     1 0 0 0 1
Line 75: Line 75:
 </​code> ​ </​code> ​
  
-**7.10.** Write a function which returns a list of all positions which have pixels of larger intensity than x+**7.8.** Write a function which returns a list of all positions which have pixels of larger intensity than x
 <code scala> <code scala>
 def largerPos(img:​ Img, int: Int): List[(Int,​Int)] = ??? def largerPos(img:​ Img, int: Int): List[(Int,​Int)] = ???
 </​code>​ </​code>​
  
-**7.11.** Write a function which adds ''​x''​ to the intensity of each pixel.+**7.9.** Write a function which adds ''​x''​ to the intensity of each pixel.
 <code scala> <code scala>
 def contrast(x: Int)(img: Img): Img = ??? def contrast(x: Int)(img: Img): Img = ???
 +</​code>​
 +
 +**7.10.** Write a function which takes two images ''​X''​ and ''​Y''​ and //glues// them on the horizontal axis (the resulting image will be ''​XY''​)
 +<code scala>
 +def hglue(img1: Img, img2: Img): Img = ???
 +</​code>​
 +
 +**7.11.** Write a function which takes two images ''​X''​ and ''​Y''​ and //glues// them on the vertical axis:
 +<code scala>
 +def vglue(img1: Img, img2: Img): Img = ???
 </​code>​ </​code>​
  
Line 99: Line 109:
 </​code> ​ </​code> ​
  
-**7.14.** Define a function which builds an effect of intensity x as shown below:+**7.14. ​(!) ** Define a function which builds an effect of intensity x as shown below:
 <code scala> <code scala>
 val img2 = List( val img2 = List(