21.01.2015 Views

COMSOL Multiphysics™

COMSOL Multiphysics™

COMSOL Multiphysics™

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

flim2curve<br />

Purpose<br />

flim2curve<br />

Create 2D curve object from image data.<br />

Syntax<br />

Description<br />

[c,r] = flim2curve(I,fmt,...)<br />

[c,r] = flim2curve(I,fmt,...) creates a curve2 object c and small curve2<br />

objects r from the image I (gray-scale or RGB) operated upon by parameters<br />

contained in the cell-array fmt. c is a curve2 object that approximates the contours<br />

of I. r is a cell-array of curve2 objects containing small curves detected by the<br />

argument. This is very useful for images containing noise. I is either an m-by-n<br />

intensity image matrix or an m-by-n-by-3 RGB-image matrix as typically obtained<br />

from the function imread. fmt is a cell-array of length 2 used to create contours<br />

from I. If fmt{2} is empty then the scalar fmt{1} is used as a threshold value. If<br />

instead, fmt{1} is empty, then the vector fmt{2} is used to specify the contour<br />

levels of interest. See the function contourc for an explanation of the contour level<br />

syntax in fmt{2}. All flmesh2spline properties are supported.<br />

c = flim2curve(i,fmt,...) is an alternative syntax and is equivalent to c =<br />

geomcsg({},{c,r{:}}) where the arguments c and r are those obtained from the<br />

other call. This is less stable whenever i contain small structures.<br />

Examples<br />

Create contour-curves from function.<br />

[x,y] = meshgrid(linspace(-3,3,50));<br />

z = (x.^2+y.^2).*exp(-x.^2-y.^2)+cos(y)+sin(x);<br />

figure<br />

imagesc(z)<br />

g = flim2curve(z,{[],[-1.5:0.5:2]});<br />

figure<br />

geomplot(g,'Pointmode','off');<br />

Create curves from noisy picture. This example does not work in <strong>COMSOL</strong> Script<br />

because it uses the mri.mat file available in MATLAB.<br />

load mri<br />

pic = D(:,:,1,10);<br />

figure<br />

image(pic)<br />

v = axis;<br />

[c,r] = flim2curve(pic,{[],1:30:91},'KeepFrac',0.10);<br />

figure<br />

geomplot(c,'Pointmode','off');<br />

Plot all small curves in a green color.<br />

for j = 1:length(r)<br />

hold on<br />

geomplot(r{j},'Pointmode','off','edgecolor','g')<br />

183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!