Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
fp:assig-02 [2021/05/14 21:07] dmihai created |
fp:assig-02 [2021/05/28 11:05] (current) dmihai |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Deadline: May 28th, 23:55** | + | **Deadline: May 31th, 23:55** |
===== Introduction ===== | ===== Introduction ===== | ||
Line 9: | Line 9: | ||
===== 1. Common transformations (0.4p) ===== | ===== 1. Common transformations (0.4p) ===== | ||
- | 1.1. **scaling** | + | 1.1. **scaling (0.2p)** |
* Scaling takes two factors (vertical and horizontal) and produces a new image with dimensions equal to that of the original multiplied by the given factor; scaling an image with height ''h'' and width ''w'' with a vertical factor ''vf'' and an horizontal factor ''hf'' results in a new image with height ''h * vf'' and width ''w * hf''. | * Scaling takes two factors (vertical and horizontal) and produces a new image with dimensions equal to that of the original multiplied by the given factor; scaling an image with height ''h'' and width ''w'' with a vertical factor ''vf'' and an horizontal factor ''hf'' results in a new image with height ''h * vf'' and width ''w * hf''. | ||
* We will employ a very simple scaling method: | * We will employ a very simple scaling method: | ||
Line 18: | Line 18: | ||
* With a vertical scaling factor of ''1.25'' you should duplicate every fourth line | * With a vertical scaling factor of ''1.25'' you should duplicate every fourth line | ||
- | 1.2. **stamping** | + | 1.2. **stamping (0.2p)** |
* We want to paste a small version of an image on top of another one | * We want to paste a small version of an image on top of another one | ||
* Your function takes a target image, a stamp image, the coordinates of the stamp's top-left corner and a scaling factor (hint: you should apply ''scale'' on it) | * Your function takes a target image, a stamp image, the coordinates of the stamp's top-left corner and a scaling factor (hint: you should apply ''scale'' on it) | ||
Line 27: | Line 27: | ||
===== 2. Type-specific transformations (0.6p) ===== | ===== 2. Type-specific transformations (0.6p) ===== | ||
- | 2.1 **superimposition** | + | 2.1 **superimposition (0.15p)** |
* Superimposing an image on top of another with a transparency factor ''alpha'' (between ''0'' and ''1'') means combining the values of each corresponding pixel pairs using weights ''alpha'' and (1 - ''alpha'') | * Superimposing an image on top of another with a transparency factor ''alpha'' (between ''0'' and ''1'') means combining the values of each corresponding pixel pairs using weights ''alpha'' and (1 - ''alpha'') | ||
* For example, the result of superimposing the second image on top of the first with a transparency factor of 0.3 is: | * For example, the result of superimposing the second image on top of the first with a transparency factor of 0.3 is: | ||
Line 33: | Line 33: | ||
{{:fp:superimposeex.png?750|}} | {{:fp:superimposeex.png?750|}} | ||
- | 2.2 **contrast** | + | 2.2 **contrast (0.15p)** |
* We want to adjust the contrast of an image with a contrast factor. | * We want to adjust the contrast of an image with a contrast factor. | ||
* You can use the algorithm presented [[https://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/|here]]: given a contrast level ''c'', you first calculate a correction factor: $math[f = \frac{259\cdot(c + 255)}{255\cdot(259 - c)}]; then, for each pixel you change its color value to $math[f\cdot(oldValue - 128) + 128] (for RGB images, you need to this on all three color channels). | * You can use the algorithm presented [[https://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-5-contrast-adjustment/|here]]: given a contrast level ''c'', you first calculate a correction factor: $math[f = \frac{259\cdot(c + 255)}{255\cdot(259 - c)}]; then, for each pixel you change its color value to $math[f\cdot(oldValue - 128) + 128] (for RGB images, you need to this on all three color channels). | ||
* Also make sure that all resulting new values are in the range 0-255! | * Also make sure that all resulting new values are in the range 0-255! | ||
- | 2.3 **bordering** | + | 2.3 **bordering (0.15p)** |
* Add a solid border with a given thickness around the image, on each side | * Add a solid border with a given thickness around the image, on each side | ||
* The color of the border should be the average color of the image (so you need to calculate that first) | * The color of the border should be the average color of the image (so you need to calculate that first) | ||
- | 2.4 **blur** | + | 2.4 **blur (0.15p)** |
* We will implement the simplest form of blurring: each new pixel will be the arithmetic mean of the original pixel and the pixel directly below it. | * We will implement the simplest form of blurring: each new pixel will be the arithmetic mean of the original pixel and the pixel directly below it. | ||
* For the last line, for which there are no pixels below, you can use any of these approaches: | * For the last line, for which there are no pixels below, you can use any of these approaches: | ||
Line 100: | Line 100: | ||
==== Submission ==== | ==== Submission ==== | ||
- | 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 "_"). Upload it to TODO | + | For submitting 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 "_"). Upload the archive to [[https://curs.upb.ro/mod/assign/view.php?id=300279|the corresponding activity]] on moodle. |