# Calculating the eigenvalues of simple shapes

조회 수: 4 (최근 30일)
John Bach 2023년 3월 13일
편집: John Bach 2023년 3월 25일
Hi there,
I've used the strel function to create a range of shapes and I would like to now calculate the eigenvalues of each shape although I am struggling to do this and would really appreciate any help regarding this.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
the cyclist 2023년 3월 13일
편집: the cyclist 2023년 3월 13일
Do you have a reference for what the eigenvalue of a binary shape is? I did some googling of keywords, but didn't find something definite. (Maybe this is well known in image processing, but that is not my specialty.)
Are you stuck on the math of it, or the MATLAB coding? Have you written any code?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Walter Roberson 2023년 3월 13일
M = double(strel('disk',5).Neighborhood)
M = 9×9
0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0
E = simplify(eig(sym(M)))
E =
vpa(E)
ans =
(the imaginary component is due to round-off error)
M2 = double(strel('octagon',12).Neighborhood)
M2 = 25×25
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
E2 = simplify(eig(sym(M2)))
E2 =
vpa(imag(E2))
ans =
vpa(E2)
ans =
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Bjorn Gustavsson 2023년 3월 15일
The/One benefit of using svd instead of eig is that one get real singular values - which is not a guarantee with eig. Appart from that the soutions should be comparable/similar/identical.

댓글을 달려면 로그인하십시오.

### 추가 답변 (1개)

Bjorn Gustavsson 2023년 3월 13일
If you have a binary image then why not just run through the svd and see what you get:
I = zeros(256);
I(64:(64+128),64:(64+128)) = 1;
[U,S,V] = svd(I);
figure
subplot(1,2,1)
plot(diag(S))
subplot(1,2,2)
imagesc(U(:,1)*S(1,1)*V(:,1)')
% Or for a funnier example:
I = numgrid('B',258);
I = I(2:end-1,2:end-1);
[U,S,V] = svd(I);
subplot(2,2,1)
plot(diag(S))
subplot(2,2,2)
imagesc(U(:,1)*S(1,1)*V(:,1)')
subplot(2,2,2)
imagesc(U(:,1:4)*S(1:4,1:4)*V(:,1:4)')
subplot(2,2,2)
imagesc(U(:,1:16)*S(1:16,1:16)*V(:,1:16)')
You can also look at the individual eigen-images by something like:
imagesc(U(:,7)*V(:,7)')
HTH

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by