image fit
awirsing
w[0]*(x-w[3])^2 + w[1]*(y-w[4])^2 +2*w[2]*(x-w[3])*(y-w[4]) - 1 < 0 ? 0 : 255
where w is also the coefficient wave to be optimized by the fit. The attached png shows also a contour plot whose 2D wave is calculated with the above formula and the coefficients
w[0]= {0.0019,0.0025,-0.00015,25,23}
. It meets the original image quite good, but it is nevertheless a manual fit and I want to use Igor's fitting routines.Does anybody know how to start here or even have a better approach?
Andreas Wirsing
I don't think you can use ordinary curve fitting because you're not fitting values.
I think you might be able to use Optimize if you can come up with a suitable merit function that has a maximum or minimum when the ellipse coefficients are optimum. Maybe something along the lines of a penalty function that sums the number of pixels that are in the wrong region- that is, white pixels inside the ellipse and black pixels outside it both increment the merit (or I guess in this case, penalty) function.
I foresee difficulties, though, because the values are rough- the penalty function will change value abruptly as each pixel is added or removed. That kind of function is difficult for ordinary optimizers.
You might refine the function by adding fractional pixels for the pixels that fall on top of the ellipse- add just the fraction of the pixel that is on the wrong side of the ellipse. That would make the function smoother.
There is probably a better technique, but I don't know what it is :)
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 11, 2010 at 10:19 am - Permalink
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
January 11, 2010 at 10:41 am - Permalink
The built-in ImageAnalyzeParticles provides a method for computing the fitting ellipse. The various moments are calculated by the operation and the fitting ellipse is computed by the WMImageDoPartEllipse() procedure in the file: WaveMetrics Procedures:Image Processing:Image Particle Panel.ipf.
I hope this helps,
A.G.
WaveMetrics, Inc.
January 11, 2010 at 11:06 am - Permalink
This was exactly, what I was looking for. Thanks a lot.
Andreas
January 11, 2010 at 11:28 pm - Permalink