3

I'm new to matlab and try to do some energy minimization work with it. The energy function takes a 3-channel image as input. For every channel, there's a energy term looks like this:

E = x'Ax + ||Bx||^2 + w*||x-c||^2,

where x,c are vectors of length N, A is a matrix of size N*N. A is sparse and positive semi-definite and has 25 non-zero elements per row, giving constraints to all elements of x. B is of size M*N. B is sparse too and has 2 non-zero elements per row. N is about 850,000. M is about 1,000,000. Although B gives more than N constraints, some elements of x have nothing to do with ||Bx||^2 term. The weight w of term ||x-c||^ is quite small, say 1e-3.

I've searched matlab documentation. It looks like I should use lsqnonlin for this problem. Is there a special designed function or option for quadratic form minimization in matlab?

For those who are familiar with computer vision literature, I'm actually trying to implement the algorithm in "Coherent Intrinsic Images from Photo Collections". The authors said they use matlab backslash operator to minimize the energy, but I can't see how a backslash operator can be used in quadratic form problem.

Bei
  • 71
  • 6
  • 1
    Can you decompose `A` as `A = C'*C`? – Shai May 18 '14 at 11:55
  • 2
    @Shai I think so. Do you mean that I should decompose (A+B'B) as (A+B'B = C'C), and solve Cx=0? Thank you! It's basic math but really works. By the way, will matalb guarantee a minimum norm solution? – Bei May 19 '14 at 02:07
  • 1
    For an overcomplete system, Matlab's backslash solution for `Cx=0` is least squares, that is minimizing `||Cx||^2||` – Shai May 19 '14 at 05:47

1 Answers1

1

Yes, there is a function specifically for optimizing quadratic cost functions: quadprog. However, if you don't have any linear constraints, then you should be able to write your cost function as

E = x'Mx/2 + vx + k

Finding the point of zero gradient (hopefully a minimum) can then be achieved by taking first derivatives:

dE/dx = Mx + v

setting them to zero giving the solution:

x = -M\v
user664303
  • 2,053
  • 3
  • 13
  • 30