Upload
deepakabc
View
218
Download
0
Embed Size (px)
DESCRIPTION
Image tiling algorithm
Citation preview
BME-Paris Master - UE Math 2
Project : Image tiling
In this project we write an algorithm for removing boundary effects when tiling images. Thiswill be done through the minimization of an energy functional.
We consider a grayscale image of size M N , represented by a vector
y = (yi,j)1iM,1jN RMN .
We want to produce a tiling of the image y, which means we want to repeat several times thesame image y in left-right and up-down directions. This procedure produces boundary effects,as can be noticed in the figure below, and we will see how these can be removed by slightlychanging pixel intensities of image y close to the boundaries. this will be done through theoptimization of an appropriate energy functional.
Tiling images in Matlab1. Write a function Y = Tiling(y,n) that takes as inputs the matrix y, and returns the
matrix Y corresponding to tiling image y n times in both directions.2. Load the image "quilt.png" to be processed and display it and its tiled version on the
screen with the Matlab commands
y = double(imread(quilt.png));figure(1); clf; colormap grayimagesc(y); axis imageY = Tiling(y,2);figure(2); clf; colormap grayimagesc(Y);axis image
The optimization problemWe define the energy E by
x RMN , E(x) =M1i=1
N1j=1
Gi,j(x y) + (
Mi=1
Ai(x) +Nj=1
Bj(x)
),
where > 0 is a fixed parameter, and z = (zi,j) RMN ,
Gi,j(z) = (zi+1,j zi,j)2 + (zi,j+1 zi,j)2,
Ai(z) = (zi,1 zi,N)2,Bj(z) = (z1,j zM,j)2,
3. Write the expression of the differential form of functional E.4. Write a function G = GradEnergy(x,y,lambda) which returns the gradient of functionalJ at x.
5. Write a Matlab function x = minimize(y,lambda,eta,n) that implements the gradientdescent algorithm for the unconstrained minimization of functional E. The parameterseta and n correspond respectively to the gradient step and the number of iterations. Theresult x is a M N matrix. The initialization of x will be made with x=y.
6. Run the previous algorithm with lambda=1, eta=0.1 and n=500, then display the resultingimage x and its tiling in separate figures. Compare the result with the tiling of the originalimage.
7. To check that convergence of the algorithm is attained, you can compute the value offunctional E at each of the n steps of the projected gradient descent. This involves writinga function E = Energy(x,y,lambda) which computes functional E, and modifying thefunction minimize so that it returns also a vector of length n containing all these values.Then you can look at this vector of values or plot it to check convergence.
8. Comment the different parts of the formula for the energy functional E and try to explainwhy it is appropriate for this problem.
2