Code covered by the BSD License  

Highlights from
patch_rasterize

Be the first to rate this file! 7 Downloads (last 30 days) File Size: 2.2 KB File ID: #41744
image thumbnail

patch_rasterize

by

 

Rasterization of a 2D triangulation

| Watch this File

File Information
Description

patch_rasterize Rasterization of a 2D triangulation
    patch_rasterize rasterize a 2D triangulation into a image. The function
    returns an image rasterizing the triangulation. This image is similar
    to the one used for OpenGL's glSelectBuffer for fast "picking".
  
    I = patch_rasterize(p) creates an image of size=max(p.vertices). If the
    f-th triangle p.faces(f,:) contains the pixels at position (i,j) then
    I(i,j)=f.
 
    Once I has been computed, retrieving a the index of the triangle
    containing the point (x,y) can be achieved by f = I( round(x), round(y) )
 
    The function run without parameters executes Example 1.
    
    Example 1:
       clc, clear, close all;
       % generate some data
       P = gallery('uniformdata',[100 2],0);
       DT = delaunayTriangulation(P);
       p.faces = DT.ConnectivityList;
       p.vertices = DT.Points * 300;
       % rasterize it
       I = patch_rasterize(p);
       figure, hold on;
       imagesc(I); axis image;
       triplot(p.faces, p.vertices(:,1), p.vertices(:,2), 'color', 'white');
       
    See also patch, triangulation,

MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us