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:
Table 6-10:
Property/Value Pairs for the mphimage2geom Command.
Property
Property value
Default
Description
compose
on
|
off
on
Create compose nodes for overlapping solids
curvetype
auto
|
polygon
auto
Type of curve to create the geometry object
geom
Geometry node
geom1
Geometry creation
minarea
Value
1
Minimum area for interior curves (in square pixels)
mindist
Value
1
Minimum distance between coordinates in curves (in pixels)
modeltag
String
Model
Model tag in a COMSOL
server
rectangle
on
|
off
off
Insert rectangle in the geometry
rtol
Value
1e-3
Relative tolerance for interpolation curves
scale
Value
1
Scale factor from pixels to geometry scale
type
solid
|
closed
|
open
solid
Type of geometry object
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);