Adding imported image as texture to 2D patch
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Noam Azulay
il 19 Lug 2021
Commentato: Noam Azulay
il 29 Lug 2021
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 Commenti
Risposta accettata
Harikrishnan Balachandran Nair
il 28 Lug 2021
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');
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Colormaps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!