Create The Image Laplacian Matrix Effectively
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I want to build the Spatial Laplacian of a given operation on an image.
The Matrix is given by:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163735/image.png)
The matrix Dx / Dy is the forward difference operator -> Hence its transpose is the backward difference operator.
The matrix Ax / Ay is diagonal matrix with weights which are function of the gradient of the image.
It is defined by:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163736/image.png)
Where Ix(i) is the horizontal gradient of the input image at the i-th pixel.
As said above Ax(i, j) = 0, i ~= j.
It is the same for Ay with the direction modification.
Assuming input Image G -> g = vec(G) = G(:).
I want to find and image U -> u = vec(U) = U(:) s.t.:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163738/image.png)
How can I solve it most efficiently in MATLAB?
How should I build the sparse Matrices?
Thank You.
2 件のコメント
Matt J
2014 年 6 月 4 日
It looks like deconvreg in the Image Processing Toolbox does the above (or something similar), but without linear algebraic methods, probably.
採用された回答
Matt J
2014 年 6 月 3 日
[M,N]=size(inputImage);
g=inputImage(:);
Dx=diff(speye(N),1,1);
Dx=kron(Dx,speye(M));
Dy=diff(speye(M),1,1);
Dy=kron(speye(N),Dy);
sp=@(V) spdiags(V(:),0,numel(V),numel(V));
Ax=sp(Dx*g);
Ay=sp(Dy*g);
Lg=Dx.'*Ax*Dx + Dy.'*Ay*Dy;
u=(speye(size(Lg))+lambda*Lg)\g;
2 件のコメント
Matt J
2014 年 6 月 3 日
Hi Royi,
- Yes, probably.
- Ax=sp(exp(-(Dx*g)/2/alpha^2)). Or implement Dx*g using diff() as you mentioned.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!