Adding imported image as texture to 2D patch
14 ビュー (過去 30 日間)
古いコメントを表示
Noam Azulay
2021 年 7 月 19 日
コメント済み: Noam Azulay
2021 年 7 月 29 日
Hello,
I have these x,y,z coordinates to create a circular sector (pizza slice shape):
theta=7*pi/18:pi/40:28*pi/45;
x=[1.8235 0.172*cos(theta)+1.8235 1.8235];
y=[0.75 0.172*sin(theta)+0.75 0.75];
z=3*ones(1,12);
I have an imported image (jpg/png) and I want it to appear on this patch. An image of an example of what I mean is attached here.
How can this be done?
I read about the function "imread", and the use of the "surface" function, but didn't manage to accomplish what I am aiming for.
0 件のコメント
採用された回答
Harikrishnan Balachandran Nair
2021 年 7 月 28 日
From my Understanding, you are having an issue in adding an imported image as texture to a circular sector. Using surf function allows you to add texture to your surface, by giving the imported image as the fourth input , and setting the ‘FaceColor’ Property to ‘texture’. To define a circular sector surface, you can calculate the points inside the sector and use it as the grid. You can refer to the following code.
k=0:pi/32:pi/4;
p=0:0.1:1;
X=ones(numel(k),numel(p));
Y=ones(numel(k),numel(p));
for i=1:numel(k)
for j=1:numel(p)
X(i,j)=p(j)*cos(k(i));
Y(i,j)=p(j)*sin(k(i));
end
end
Z=3*ones(numel(k),numel(p));
i=imread('image.jpg');
surf(X,Y,Z,i,'FaceColor','texture','EdgeColor','none');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!