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:assig-01 [2021/04/26 12:17]
dmihai [Tasks (total 1p)]
fp:assig-01 [2021/05/06 17:32] (current)
dmihai [Submission]
Line 1: Line 1:
-==== Introduction ====+**Deadline: May 7th, 23:55** 
 + 
 +===== Introduction ​=====
  
 For this assignment, we will work with images and implement some basic image manipulations. For this assignment, we will work with images and implement some basic image manipulations.
Line 18: Line 20:
 For these two formats (greyscale and RGB) you are asked to implement some transformations. The next section lists common transformations (that should not depend on whether the pixel is a grayscale value or a RGB triplet); the section after that describes transformations that should have separate implementations,​ one for each format. For these two formats (greyscale and RGB) you are asked to implement some transformations. The next section lists common transformations (that should not depend on whether the pixel is a grayscale value or a RGB triplet); the section after that describes transformations that should have separate implementations,​ one for each format.
  
-===== 1. Basic transformations (0.4p) =====+===== 1. Common ​transformations (0.2p) =====
  
 1.1. **vertical flip** 1.1. **vertical flip**
Line 32: Line 34:
 1.6. **180 degree right-rotation** 1.6. **180 degree right-rotation**
  
-1.7. **color inversion** +===== 2Type-specific transformations (0.8p) =====
-       * you will have to flip a color value to the other side of the 0-255 interval+
  
-===== 2. Image alteration (0.6p) ===== 
  
-2.1.  **cropping with a rectangle selection** +2.1. **color inversion** 
-            * your function should take a rectangle modelled by a ''​(Int,​ Int, Int, Int)''​ tuple (the first two ''​Int''​s are the coordinates of the top-right corner, the next two ''​Int''​s are the height and width of the rectangle). It should return a new image with the same height and width as the rectangle selection containing the pixels in the image which fall withing the rectangle'​s area.+       * you will have to flip a color value to the other side of the 0-255 interval 
 +      
 +2.2.  **cropping with a rectangle selection** 
 +            * your function should take a rectangle modelled by a ''​(Int,​ Int, Int, Int)''​ tuple (the first two ''​Int''​s are the coordinates of the top-left corner, the next two ''​Int''​s are the height and width of the rectangle). It should return a new image with the same height and width as the rectangle selection containing the pixels in the image which fall withing the rectangle'​s area.
  
-2.2.  **brightness adjustment**+2.3.  **brightness adjustment**
         * your function should take an adjustment value (an ''​Int''​) with which to increase the value of each color (remember that 0 is black and 255 is the pure color, either white for greyscale, or R/G/B for color images).         * your function should take an adjustment value (an ''​Int''​) with which to increase the value of each color (remember that 0 is black and 255 is the pure color, either white for greyscale, or R/G/B for color images).
  
-2.3. **masking with a bitmap mask**+2.4. **masking with a bitmap mask**
             * your function should take a mask represented as a two-dimensional bitmap with the same size as the image (a ''​[%%[%%Bool]%%]%%''​). The resulting image should look like this: if the mask has ''​False''​ at position ''​(x,​ y)''​ the pixel at position ''​(x,​ y)''​ is black; otherwise it retains its original value.             * your function should take a mask represented as a two-dimensional bitmap with the same size as the image (a ''​[%%[%%Bool]%%]%%''​). The resulting image should look like this: if the mask has ''​False''​ at position ''​(x,​ y)''​ the pixel at position ''​(x,​ y)''​ is black; otherwise it retains its original value.
  
-2.6. **color swapping**+2.5. **color swapping**
             * //this transformation is relevant only for RGB images//​. ​ Your function should swap the colors for each pixel (the exact permutations is your choice).             * //this transformation is relevant only for RGB images//​. ​ Your function should swap the colors for each pixel (the exact permutations is your choice).
  
-2.7. **conversion to greyscale**+2.6. **conversion to greyscale**
             * //this transformation is relevant only for RGB images.//​. ​ Your function should convert an RGB image (''​[%%[%%(Int,​ Int, Int)]%%]%%''​) to a greyscale one (''​[%%[%%Int]''​). For each pixel, you can set the grey intensity to the average of its three colors.             * //this transformation is relevant only for RGB images.//​. ​ Your function should convert an RGB image (''​[%%[%%(Int,​ Int, Int)]%%]%%''​) to a greyscale one (''​[%%[%%Int]''​). For each pixel, you can set the grey intensity to the average of its three colors.
  
Line 62: Line 65:
 Our focus here is simply on how to program in a functional style, so we don't really aim for performance and smooth results. Our focus here is simply on how to program in a functional style, so we don't really aim for performance and smooth results.
  
-For example, the scaling algorithm presented (a form of [[https://​en.wikipedia.org/​wiki/​Nearest-neighbor_interpolation|nearest-neighbor]] ​interpolation}) is easy to write, but its results are poor.+For example, the scaling algorithm presented (a form of [[https://​en.wikipedia.org/​wiki/​Nearest-neighbor_interpolation|nearest-neighbor ​interpolation]]) is easy to write, but its results are poor.
 You can see [[https://​en.wikipedia.org/​wiki/​Comparison_gallery_of_image_scaling_algorithms|here]] a quality comparison of various algorithms. You can see [[https://​en.wikipedia.org/​wiki/​Comparison_gallery_of_image_scaling_algorithms|here]] a quality comparison of various algorithms.
  
Line 71: Line 74:
 For very basic testing, you can define your own test-cases. However, to give you a big-picture view and some satisfying results, we offer you a testing framework for [[https://​en.wikipedia.org/​wiki/​Netpbm#​File_formats|Netpbm]] ASCII-format images. For very basic testing, you can define your own test-cases. However, to give you a big-picture view and some satisfying results, we offer you a testing framework for [[https://​en.wikipedia.org/​wiki/​Netpbm#​File_formats|Netpbm]] ASCII-format images.
  
-Netpbm a simplistic pixel-map image format, capable of modelling both greyscale and RGB pictures.+Netpbm ​is a simplistic pixel-map image format, capable of modelling both greyscale and RGB pictures.
  
 A Netpbm image file has the following structure: A Netpbm image file has the following structure:
Line 97: Line 100:
   * for single image transformations (i.e. all except masking), edit line 13. The following example will configure it with a crop of a 50x50 square that starts at coordinates (30, 30):   * for single image transformations (i.e. all except masking), edit line 13. The following example will configure it with a crop of a 50x50 square that starts at coordinates (30, 30):
     * <​code>​myTransform img = crop (30, 30, 80, 80) img</​code>​     * <​code>​myTransform img = crop (30, 30, 80, 80) img</​code>​
-  * for transformations that require ​to images (just masking), line 16 is relevant; but you can leave it as it is, as there'​s only one transformation candidate.+  * for transformations that require ​two images (just masking), line 16 is relevant; but you can leave it as it is, as there'​s only one transformation candidate.
  
 After having edited ''​Main.hs''​ you can run it; depending on the number of arguments, it will choose an appropriate type of transformation (single/​multiple image); it also correctly chooses between greyscale/​RGB functions based on the actual filetype. To run the file you need the ''​runhaskell''​ binary (or ''​runghc'';​ both should come with the haskell platform), then run it from a shell: After having edited ''​Main.hs''​ you can run it; depending on the number of arguments, it will choose an appropriate type of transformation (single/​multiple image); it also correctly chooses between greyscale/​RGB functions based on the actual filetype. To run the file you need the ''​runhaskell''​ binary (or ''​runghc'';​ both should come with the haskell platform), then run it from a shell:
Line 121: Line 124:
 ==== Submission ==== ==== Submission ====
  
-For submission you should create a zip archive of the two files you modified: ''​Greyscale.hs''​ and ''​Color.hs''​ and a ''​README''​. The ''​README''​ should contain a succinct high-level presentation of your work. The archive name should be ''​LASTNAME_Firstname_FP_A1.zip''​ (if you have multiple firstnames, separate them by an underline "​_"​). Mail it to [[mailto:​mihai.dumitru2201@upb.ro|mihai.dumitru2201@upb.ro]].+For submission you should create a zip archive of the three files you modified: ​''​Common.hs'', ​''​Greyscale.hs''​ and ''​Color.hs''​ and a ''​README''​. The ''​README''​ should contain a succinct high-level presentation of your work. The archive name should be ''​LASTNAME_Firstname_FP_A1.zip''​ (if you have multiple firstnames, separate them by an underline "​_"​). Mail it to [[mailto:​mihai.dumitru2201@upb.ro|mihai.dumitru2201@upb.ro]].