11.45 Sample ‘detect

Example of curve detect.

MGL code:

subplot 1 1 0 '':title 'Detect sample'
new a 200 100 'exp(-30*(y-0.5*sin(pi*x))^2-rnd/10)+exp(-30*(y+0.5*sin(pi*x))^2-rnd/10)+exp(-30*(x+y)^2-rnd/10)'
ranges 0 a.nx 0 a.ny:box
alpha on:crange a:dens a

detect r a 0.1 5
plot r(0) r(1) '.'

C++ code:

void smgl_detect(mglGraph *gr)
{
	mglData a(200, 100);
	gr->Fill(a,"exp(-30*(y-0.5*sin(pi*x))^2-rnd/10)+exp(-30*(y+0.5*sin(pi*x))^2-rnd/10)+exp(-30*(x+y)^2-rnd/10)");
	gr->SubPlot(1,1,0,"");
	if(big!=3)	gr->Title("Detect sample");
	gr->SetRanges(0,a.nx,0,a.ny);	gr->SetRange('c',a);
	gr->Alpha(true);	gr->Box();	gr->Dens(a);
	mglData r(a.Detect(0.1,5));
	gr->Plot(r.SubData(0), r.SubData(1), ".");
}
Sample detect