comp-imaging / ProxImaL

A domain-specific language for image optimization.
MIT License
114 stars 29 forks source link

Applying operators to input image #35

Closed multigrid101 closed 7 years ago

multigrid101 commented 7 years ago

Sometimes, it is desirable to apply operators to the input image, e.g. in optical flow.

I cannot figure out if this is even possible. I tried defining e.g. (this functional makes no sense, its just supposed to be a minimum example).

I = imread(...) # read input picture
x = Variable(*I.shape)
prob = Problem( grad(I) - grad(x)) + sum_squares(v1)
prob.solve()

but I end up with some error because the problem contains grad(I). The actual error differs, depending on what I'm actually trying to do in my functional.

I know that I could substitute grad(I-x) above but that trick will not work for arbitrary combinations of the operators (I actually need something like sum_squares(mul_elemwise(grad(I,1),x))).

So I guess the big question is: Is it currently possible in proximal to define problems by applying operators to input images, or do I need to make the appropriate transformations by hand?

Thanks in advance :)

SteveDiamond commented 7 years ago

The syntax prob = Problem( grad(I) - grad(x)) + sum_squares(v1) doesn't make sense. The problem object contains the objective.

You can do `sum_squares(mul_elemwise(grad(I,1).value,x))). I guess it doesn't automatically evaluate to a constant right now.