get projection image without rendering to screen
3 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
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 件のコメント
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
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!