-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b44c6de
commit 627d87f
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
LAB/eserciziCasa/sperimentazioniImmagini/sperimentazioniImmagini.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
PImage Im, ImN, ImG, ImL; | ||
void setup(){ | ||
size(500,500); | ||
Im = loadImage("napule.png"); | ||
ImG = loadImage("yuri.jpg"); | ||
Im.resize(256,256); | ||
ImG.resize(256,256); | ||
image(Im,0,0); | ||
|
||
|
||
ImN = negativo(Im); | ||
ImL = negativo(ImG); | ||
image(ImL,0,256); | ||
image(ImN,256,0); | ||
image(ImG,256,256); | ||
} | ||
|
||
|
||
|
||
PImage negativo(PImage I){ | ||
PImage R = I.copy(); | ||
R.loadPixels(); | ||
|
||
float r,g,b; | ||
for(int i=0; i<R.pixels.length;i++){ | ||
r = 255-red(R.pixels[i]); | ||
g = 255-green(R.pixels[i]); | ||
b = 255-blue(R.pixels[i]); | ||
|
||
R.pixels[i] = color(r,g,b); | ||
} | ||
R.updatePixels(); | ||
return R; | ||
} |