Adding imported image as texture to 2D patch

16 visualizaciones (últimos 30 días)
Noam Azulay
Noam Azulay el 19 de Jul. de 2021
Comentada: Noam Azulay el 29 de Jul. de 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.

Respuesta aceptada

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair el 28 de Jul. de 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');

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by