i cant use interpolation in matlab

조회 수: 5 (최근 30일)
ibrahim çömez
ibrahim çömez 2022년 3월 30일
댓글: Chandra 2022년 4월 28일
I wanted to get the edges of the images and interpolate them to create a 3D image. But interp3 works incorrectly or not at all.
can someone help me? how can I create a 3D image with interpolation?
how can i add interp3 to this code ?
A=imread('1-173Final.png');
C=double(A);
for i=1:size(C,1)-2
for j=1:size(C,2)-2
Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2)));
Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));
B(i,j)=sqrt(Gx.^2+Gy.^2);
end
end
[x y z] = ind2sub(size(B), find(B));
figure(1)
plot3(x, y, z, 'k.');
P=imread('1-171Final.png');
V=double(P);
for i=1:size(V,1)-2
for j=1:size(V,2)-2
Gx=((2*V(i+2,j+1)+V(i+2,j)+V(i+2,j+2))-(2*V(i,j+1)+V(i,j)+V(i,j+2)));
Gy=((2*V(i+1,j+2)+V(i,j+2)+V(i+2,j+2))-(2*V(i+1,j)+V(i,j)+V(i+2,j)));
L(i,j)=sqrt(Gx.^2+Gy.^2);
end
end
[q w e] = ind2sub(size(L), find(L));
hold on
e=e+0.01;
plot3(q, w, e, 'b.');
hold off

채택된 답변

Chandra
Chandra 2022년 4월 5일
Hi,
'interp3' expects the x,y,z,v inputs in meshgrid ordering
>> Vq3 = interp3(y,x,z,v,Yq,Xq,Zq); % meshgrid order for X, Y, Z, V
For more information, please refer to the documentation pages:
  댓글 수: 22
Walter Roberson
Walter Roberson 2022년 4월 27일
I am confused about what k (lower-case) is in your suggestion? I do not see a k in the user code? I see a K (capital), but the user K has three panes, and interp3() by default subdivides every dimension once, so interp3() of something N x M x 3 would give a result that is (2*N-1) by (2*M-1) by 5, and you cannot imshow() something that has more than 1 pane.
I do not understand where the 3 color panes you are talking about come from?
Chandra
Chandra 2022년 4월 28일
Here the images in B and L are considered as a 2D matrix as I assumed from the code mentioned, so after applying the "interp3" the output will be (2*M-1)x(2*N-1)x3, as K is two MxN matrix, here depending on the assigning value we can use k in interp3, if images are assigned to K(capital) then
k = interp3(K); % K capital in interp3 and k small in assigned value
imshow(k,[]);
%OR
K = interp3(K); % K capital in interp3 and k capital in assigned value
imshow(K,[]);

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by