i cant use interpolation in matlab

6 ビュー (過去 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 Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by