-
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
jphilippeplante
committed
Dec 2, 2007
1 parent
4514d33
commit 228a222
Showing
160 changed files
with
467,003 additions
and
0 deletions.
There are no files selected for viewing
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="unit_tests"/> | ||
<classpathentry kind="src" path="integration_tests"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="lib/mtj.jar"/> | ||
<classpathentry kind="lib" path="lib/jlapack.jar"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>PoissonImageEditing</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,3 @@ | ||
#Sun Oct 21 11:57:58 EDT 2007 | ||
eclipse.preferences.version=1 | ||
encoding/<project>=UTF-8 |
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,102 @@ | ||
Provenant de imagelib: ImageBGRb, ImageLb, GraphicsEx, LoadImageFailedException, SaveImageFailedException | ||
|
||
Description du flow | ||
=================== | ||
source image, source mask, dest image (as files) | ||
offset x, y | ||
RGB, mask as bytes | ||
|
||
load all files | ||
check (input image size == input mask size) | ||
verify mask | ||
- check que le mask fit dans la destination (bust la destination) | ||
- check que le mask contient uniquement les valeurs permises | ||
- check que la selection ne bleed pas sur les bordures (nord, sud, est, ouest) | ||
créer une version des image (taille de l'image dest) | ||
- source qui est "collé" dans une image vide (clone simple) a l'offset | ||
- meme chose pour le mask ... | ||
- a faire dans une seule boucle. | ||
Trouver l'image d'output en executant le solver de poisson | ||
sauvegarder l'image | ||
|
||
Solver de poisson | ||
================= | ||
on passe l'image dest., le mask et ... (voir etape 3) | ||
convertir l'image RGB (byte-based) en float-based suivant un ratio sur 255 pour chaque channel (ie. rf = rb / 255, gf = gb / 255) | ||
calculer le champ de gradient pour l'image source cloné trivialement (et stocker ou passer en param...) | ||
********** | ||
// ce code est stupide il perd du temps a calculer des pixels que l'on utilisera pas... | ||
for (uint y = 0; y < h-1; y++) { | ||
for (uint x = 0; x < w-1; x++) { | ||
// p est une cellule du champ de gradient (u, v sont les coords du vecteur en ce point) | ||
// I est l'image source trivialement cloné | ||
p.u = I(x+1,y) - I(x,y); | ||
p.v = I(x,y+1) - I(x,y); | ||
} | ||
} | ||
********** | ||
calculer le divergent du champ de gradient qu'on vient de calculer (pour finalement obtenir la matrice des laplaciens) | ||
********** | ||
for (uint y = 1; y < h; y++) { | ||
for (uint x = 1; x < w; x++) { | ||
// p est une cellule dans la matrice des laplaciens | ||
T p = I(x,y).u - I(x-1,y).u + | ||
I(x,y).v - I(x,y-1).v; | ||
O.setPixel(x,y,p); | ||
} | ||
} | ||
********* | ||
Tout ça peut etre précaculé: ce sont les parametres envoyés au solver... (see below) | ||
void Solver::solve(const ImageBGRf& Destination, const ImageLb& Mask, const ImageBGRf& divergents, ImageBGRf& Output) | ||
|
||
Remplir un hashmap avec des clés étant la position linéarisée (id = y*w+x) | ||
avec des valeurs en partant de 0 à N (soit le nombre points dans la selection du mask) (incrémente pour chaque nouveau point de selection) | ||
|
||
S'assurer que ce hashmap n'est pas vide (si c'est le cas, il n'y avait rien de vraiment sélectionné dans le masque) | ||
|
||
Ceci implique de résoudre pour N pixels inconnus (3*N en comptant les channels) | ||
|
||
Résoudre Ax = b avec les trois channels en même temps (haute concurrence sans dép., facilement parallèlisable ???) | ||
|
||
Instanciation de la matrice creuse (appelé MAT ici) (sparse matrix) de N par N avec de l'espace pour 5*N éléments non nuls (matrice de réels de type Double) | ||
JMP semble intéressant : http://www.uib.no/People/nmabh/jmp/index2.html | ||
|
||
UBER PARALLELISABLE !!!! | ||
|
||
initialiser n = 0 | ||
for(chaque pixel dans l'image destination) { | ||
s'il s'agit d'un pixel dans la sélection { | ||
uint id = y*w+x; // ID du hashmap courant (position linéarisée) | ||
extraire les 3 channels du pixel courant DANS LES DIVERGENTS (laplacien) | ||
|
||
pour les 4 voisins (check séquentiellement, pas necessairement une boucle) | ||
// si le voisin du haut est en dehors de la selection (DIRICHLET BOUNDARY CONDITION) | ||
... (this is the tricky part... je ne la comprends pas à cause de l'API merdique de TAUCS) | ||
|
||
n++ | ||
} | ||
} | ||
|
||
Assert n == N | ||
|
||
transposer la matrice creuse | ||
|
||
solve matrice transposé pour les N inconnus (3*N avec channels) | ||
il semble que ce soit présenté en décomposition LU (lower uppper) | ||
|
||
réécrire les pixels "inconnus" dans l'image destination (avec clamping de 0 à 1 au cas ou ça diverge ?!) | ||
|
||
THAT's it ! | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,36 @@ | ||
im = double(imread('../images/test002.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/test002insert.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
|
||
[imr img imb] = decomposeRGB(im); | ||
[imir imig imib] = decomposeRGB(iminsert); | ||
|
||
m = 60; | ||
endpt = 61; | ||
|
||
% imr = poisson1(m, endpt, 5, imr, imir); | ||
% img = poisson1(m, endpt, 5, img, imig); | ||
% imb = poisson1(m, endpt, 5, imb, imib); | ||
|
||
boxSrc = [20 40 20 40]; | ||
posDest = [20 20]; | ||
imr = poissonSolver(imr, imir, boxSrc, posDest); | ||
img = poissonSolver(img, imig, boxSrc, posDest); | ||
imb = poissonSolver(imb, imib, box); | ||
|
||
imnew = composeRGB(imr, img, imb); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/test002Result.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
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,37 @@ | ||
% im = double(imread('../images/orange.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(im)); | ||
% | ||
% iminsert = double(imread('../images/orange.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(iminsert)); | ||
|
||
im = double(imread('../images/test001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/test001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
|
||
[imr img imb] = decomposeRGB(im); | ||
[imir imig imib] = decomposeRGB(iminsert); | ||
|
||
boxSrc = [20 190 20 190 ]; | ||
posDest = [20 20]; | ||
imr = poissonSolver(imir, imr, boxSrc, posDest); | ||
img = poissonSolver(imig, img, boxSrc, posDest); | ||
imb = poissonSolver(imib, imb, boxSrc, posDest); | ||
|
||
imnew = composeRGB(imr, img, imb); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/test001Result.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
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,46 @@ | ||
% im = double(imread('../images/orange.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(im)); | ||
% | ||
% iminsert = double(imread('../images/orange.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(iminsert)); | ||
|
||
|
||
im = double(imread('../images/monalisaBW.tif', 'TIF')); | ||
|
||
% find the area of the white pixels | ||
n = size(find(im)) | ||
|
||
|
||
|
||
|
||
% im = double(imread('../images/test001.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(im)); | ||
% | ||
% iminsert = double(imread('../images/test001.tif', 'TIF')); | ||
% figure; | ||
% imshow(mat2gray(iminsert)); | ||
% | ||
% | ||
% [imr img imb] = decomposeRGB(im); | ||
% [imir imig imib] = decomposeRGB(iminsert); | ||
% | ||
% boxSrc = [20 190 20 190 ]; | ||
% posDest = [20 20]; | ||
% imr = poissonSolver(imir, imr, boxSrc, posDest); | ||
% img = poissonSolver(imig, img, boxSrc, posDest); | ||
% imb = poissonSolver(imib, imb, boxSrc, posDest); | ||
% | ||
% imnew = composeRGB(imr, img, imb); | ||
% | ||
% figure(100); | ||
% imshow(mat2gray(imnew)); | ||
% imwrite(mat2gray(imnew), '../images/test001Result.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
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,24 @@ | ||
im = double(imread('../images/test001BW.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/test001BW.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
|
||
% [imr img imb] = decomposeRGB(im); | ||
% [imir imig imib] = decomposeRGB(iminsert); | ||
|
||
|
||
boxSrc = [20 100 20 100]; | ||
posDest = [20 20]; | ||
imnew = poissonSolver(iminsert, im, boxSrc, posDest); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/test001BWResult.jpg', 'JPG'); | ||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
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,28 @@ | ||
im = double(imread('../images/wall001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/words.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
[imr img imb] = decomposeRGB(im); | ||
[imir imig imib] = decomposeRGB(iminsert); | ||
|
||
boxSrc = [5 195 5 195 ]; | ||
posDest = [15 15]; | ||
imr = poissonSolverInsertionHoles(imir, imr, boxSrc, posDest); | ||
img = poissonSolverInsertionHoles(imig, img, boxSrc, posDest); | ||
imb = poissonSolverInsertionHoles(imib, imb, boxSrc, posDest); | ||
|
||
imnew = composeRGB(imr, img, imb); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/wallResult.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
28 changes: 28 additions & 0 deletions
28
SmartPhotomontage/ext/poissonSolver/WSInsertionTransparent.m
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,28 @@ | ||
im = double(imread('../images/tropicalIsland.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/rainbow001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
[imr img imb] = decomposeRGB(im); | ||
[imir imig imib] = decomposeRGB(iminsert); | ||
|
||
boxSrc = [2 160 2 256 ]; | ||
posDest = [2 2]; | ||
imr = poissonSolverInsertionHoles(imir, imr, boxSrc, posDest); | ||
img = poissonSolverInsertionHoles(imig, img, boxSrc, posDest); | ||
imb = poissonSolverInsertionHoles(imib, imb, boxSrc, posDest); | ||
|
||
imnew = composeRGB(imr, img, imb); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/rainbowResult.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
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,28 @@ | ||
im = double(imread('../images/orange001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(im)); | ||
|
||
iminsert = double(imread('../images/orange001.tif', 'TIF')); | ||
figure; | ||
imshow(mat2gray(iminsert)); | ||
|
||
[imr img imb] = decomposeRGB(im); | ||
[imir imig imib] = decomposeRGB(iminsert); | ||
|
||
boxSrc = [100 190 100 190 ]; | ||
posDest = [100 100]; | ||
imr = poissonSolverLocalIllumination(imir, imr, boxSrc, posDest); | ||
img = poissonSolverLocalIllumination(imig, img, boxSrc, posDest); | ||
imb = poissonSolverLocalIllumination(imib, imb, boxSrc, posDest); | ||
|
||
imnew = composeRGB(imr, img, imb); | ||
|
||
figure(100); | ||
imshow(mat2gray(imnew)); | ||
imwrite(mat2gray(imnew), '../images/orangeResult2.jpg', 'JPG'); | ||
% poisson1(50, 51, 5); | ||
|
||
|
||
% im = double(imread('../images/test001BW.tif', 'TIFF')); | ||
% figure; | ||
% imshow(mat2gray(im)); |
Oops, something went wrong.