필터 지우기
필터 지우기

get projection image without rendering to screen

조회 수: 3 (최근 30일)
Volkan
Volkan 2011년 6월 3일
답변: George Abrahams 2024년 2월 10일
Hi,
I have an 3d model and ı want to take its 2d projection.
I can get it from rendered projection from figure with the method below succesfully.
trimesh(...
tl, shp(:, 1), shp(:, 3), shp(:, 2), ...
'EdgeColor', 'none', ...
'FaceVertexCData', tex/255, 'FaceColor', 'interp', ...
'FaceLighting', 'phong' ...
set(gca, ...
'DataAspectRatio', [ 1 1 1 ], ...
'PlotBoxAspectRatio', [ 1 1 1 ], ...
'Units', 'pixels', ...
'GridLineStyle', 'none', ...
'Position', [ 0 0 fig_pos(3) fig_pos(4) ], ...
'Visible', 'off', 'box', 'off', ...
'Projection', 'perspective' ...
);
h=gca;
F=getframe(h);
im=F.cdata;
Now, I wanna take projection image without the need of rendered to screen. Because ı used the method on an optimization process and rendering process costs so much to me.
Thanks for your time.

채택된 답변

Jonas Reber
Jonas Reber 2011년 6월 3일
you could calculate the perspective projection of your model yourself as you have all the information on camera position, look at point, etc. this ends up to a matrix multiplication (see Shirleys "Fundamentals of Computer Graphics" or Wikipedia: http://en.wikipedia.org/wiki/3D_projection#Perspective_projection)
but what you probably are looking for is the matlab function "viewmtx" (<http://www.mathworks.com/help/techdoc/ref/viewmtx.html)>?
  댓글 수: 2
Volkan
Volkan 2011년 6월 6일
Thank you Jonas,
I projected the point succesfully with the method you proposed. I used viewmtx function.
In the code which I wrote on my question, the texture data has rendered with trimesh function.
Now i projected the points on 2d space but i dont know how can i brush the area between points.(using my texture data). I have rgb color values for every vertex.
Thank you again for your support.
Jonas Reber
Jonas Reber 2011년 6월 7일
Hi Volkan,
once you have your 2D points you can use patch (http://www.mathworks.com/help/techdoc/ref/patch.html) to draw things.
Take a look at the explanation given in the documentation - it is quite good. (i.e. you need to set the 'FaceVertexCData')

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

George Abrahams
George Abrahams 2024년 2월 10일
My 3D Rendering Toolbox on File Exchange is one option for doing this. The world2image function performs the perspective projection you've calculated yourself, and a bit more.
If you're okay with 2D vector graphics (composed of polygons), i.e., you don't need a rastered image (composed of pixels), that right there is enough. Otherwise, the projection is only the first step, as you've discovered.
My toolbox also contains a rasterize function. However, given that you need interpolated face colors (from vertex colors) and face lighting, Patch Software Render or Rendering Pipeline may suit better, although I have no experience with them.

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by