mphimage2geom
Convert image data to a geometry.
Syntax
model = mphimage2geom(imagedata,level,...)
Description
model = mphimage2geom(imagedata,level,...) converts the image contained in imagedata into a geometry which is returned in the model object model.
The contour of the image is defined by the value level. imagedata must be a 2D matrix.
The function mphimage2geom accepts the following property/value pairs:
on | off
auto | polygon
on | off
solid | closed | open
The default curve types creates a geometry with the best suited geometrical primitives. For interior curves this is Interpolation Curves, and for curves that are touching the perimeter of the image, Polygons is used.
To add the geometry created with mphimage2geom, specify the geometry node with property geom.
Example
Create a set of point coordinates:
p = (peaks+7)*5;
Display contour plot of the point data:
figure(1); [c,h] = contourf(p); clabel(c, h); colorbar
Create a geometry object following the contour made with point of value 50:
model = mphimage2geom(p, 50);
figure(2); mphgeom(model)
Create the same geometry object with a scale factor of 1e-3 and add it into an existing 3D model:
model = mphopen('model_tutorial_llmatlab');
wp1 = model.component('comp1').geom('geom1').feature.create('wp1', 'WorkPlane');
wp1.set('quickz', 1e-2);
mphimage2geom(p, 50,'scale',1e-3,wp1.geom);
mphgeom(model)
Create a geometry using MRI data. The geometry object is created following the contour made with point of value 30 and disregard objects with an area (in pixel) lower than 2:
mri = load('mri');
im = mri.D(:,:,1,1);
figure(1); image(im);
mphimage2geom(im, 30,'minarea',2);