Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fp:assig-01 [2021/04/26 12:19] dmihai [2. Type-specific transformations (0.6p)] |
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 39: | Line 41: | ||
2.2. **cropping with a rectangle selection** | 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-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. | + | * 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.3. **brightness adjustment** | 2.3. **brightness adjustment** | ||
Line 63: | 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 72: | 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 98: | 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 122: | 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]]. |