Hello everyone I am a student of Communication Sciences in Cagliari, Italy. I'm new to the forum and I could use help with this exercise for an examination of the faculty:
Write a sketch that shows the effect of the number of color levels on the quality
image. To simulate the decrease in the number of levels, the sketch must introduce a
separation between one level and the next one. To achieve this, you must perform the
following steps in the following order:
1. Write the function (LeggiImmagine) which reads an image suggesting the user
window to select the file that contains it and charge it in an object PImage. the
function has no arguments and returns as a result the object Pimage.
2. As from the start of the first operation, the sketch must read the image
(by invoking the function defined in point 1) and display it.
3. Write a function (ConvertiLivelli (n, m)) that takes as parameters two numbers
integers between 2 and 256. The function transforms the original image in which each color
key is a number between 0 and (n-1), in an image in which each fundamental color is
a number between 0 and (m-1). To do so we must make the following proportion:
livello_di_colore livello_di_colore_originale * = n / m
You must do this for all levels of color intensity of all pixels in the image.
4. Write the function (Levels ()) that applies twice the function defined in ConvertiLivelli
point 3 consecutive twice: the first time with n = 3 and m = 256, the second to values
reversed, n = 256 and m = 3.
5. When the user presses any key on the sketch displays the modified image with the
Levels function defined in section 4 above if the original image was displayed
and vice versa displays the original image if the image was displayed previously
changed.
for now I could only write this:
PImage immagineSorgente;
PImage immagineDestinazione;
void LeggiImmagine() {
// carico l'immagine da disco e creo l'oggetto PImage immagineSorgente
String nomeImmagineSorgente=selectInput("Scegli l'immagine da elaborare");