i cant use interpolation in matlab

6 views (last 30 days)
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

Accepted Answer

Chandra
Chandra on 5 Apr 2022
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 Comments
Chandra
Chandra on 28 Apr 2022
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,[]);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by