필터 지우기
필터 지우기

L1 and l2 norm

조회 수: 143 (최근 30일)
hasan alhussaini
hasan alhussaini 2018년 3월 14일
답변: JMW 2019년 11월 12일
i'm trying to find the code not the function to implement L1 and L2 norm.
I'm trying to compute the L1 and L2 norm of pixels in a image to see the difference between them.

답변 (2개)

Johnathan Schaff
Johnathan Schaff 2018년 3월 15일
편집: Johnathan Schaff 2018년 3월 15일
%Matrix Norm for Matrix A
%L1 Norm
l1 = max(sum(abs(A)));
matL1 = norm(A,1);
%L2 Norm
l2 = max(svd(A));
matL2 = norm(A,2);
%Comparison
fprintf('L1 Norm | %g\nMATLAB L1 Norm | %g\n',l1,matL1);
fprintf('L2 Norm | %g\nMATLAB L2 Norm | %g\n',l2,matL2);
%Vector Norm for Vector B
%L1 Norm
l1 = (sum(abs(B)));
matL1 = norm(B,1);
%L2 Norm
l2 = sqrt(sum(abs(B).^2));
matL2 = norm(B,2);
%Comparison
fprintf('\nL1 Norm | %g\nMATLAB L1 Norm | %g\n',l1,matL1);
fprintf('L2 Norm | %g\nMATLAB L2 Norm | %g\n',l2,matL2);

JMW
JMW 2019년 11월 12일
To get column norms:
L1=vecnorm(A,1)
L2=vecnorm(A,2)

카테고리

Help CenterFile Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by