# Algorithm/Numerical Approach for Computing CI (Contrast Index)

Show 40 post(s) from this thread on one page
Page 2 of 4 First 1234 Last
• 08-31-2013, 05:05 AM
Rafal Lukawiecki
David, your equations look good. My data is zeroed at fb-f, having subtracted the y-axis min of the points, so D(x1) = 0, makes it even simpler. As it seems that the fitted smooth spline model is of high quality (p<0.01), for my curent data, and I expect it should be so for most successful film tests, the R predict(x) function will safely give me the interpolated value of D(x), using the spline, for any point I need along the range of rel logE axis. So it looks like I'm now in position to use the curve to solve your equations for the CI condition, looking for the first occurrence of it, I suppose, from left, in case the condition could be fulfilled more than once on a strange curve. Thanks for the suggestion of optimize.fsolve in scipy, that's a great tip. I will try uniroot or rootSolve/multiroot in R. If I can't make it, I'll ask for your Python. :)
• 08-31-2013, 09:59 AM
Bill Burk
Quote:

Originally Posted by dpgoldenberg
Bill,
My words may not have been as clear as I intended, but I think that the equations are correct. The equations define the distances between the points in two dimensions, not just the distance along the horizontal axis. (That's where Pythagoras comes in.) The first two equations define the distances between the first and second points (0.2) and the second and third points (2). The third equation ensures that all three lie on the same line. Also, D(x1) should be specified to be b+f.

David

Oh, I see. Sounds good
• 08-31-2013, 03:02 PM
ic-racer
Though, a little off topic, here is the "W-speed" meter that for which I made the Excel spreadsheet to imitate its function. As you can see it is more complicated than the Contrast Index Meter, however, my solution to the problem is simpler because I use linear interpolation between the datapoints, rather than a complex function for the film curve.
Attachment 73762
Attachment 73761
My Excel calculated approximation for "E" used to calculate the W-speed = the red dot. I think it is a pretty good approximation:
Attachment 73763
• 08-31-2013, 06:05 PM
Rudeofus
Rafal, the CI sort of assumes that you have a straight line as characteristic curve, while your LOESS approach most likely won't give you a straight line but some spline curve with variable slope over its range. I would therefore suggest a slightly different approach: create a model for what you expect as characteristic curve, e.g. a flat line in the b+f region, a straight line in the linear region and some form of smooth transition between these two straight lines. Once you have a model that covers all characteristic curves you are likely going to encounter, you can do an LMS fit to get the parameters for each set of measurement data. It should then be simple to associate a CI with the parameters you obtain for your model.
• 08-31-2013, 06:34 PM
ic-racer
Quote:

Originally Posted by Rudeofus
Rafal, the CI sort of assumes that you have a straight line as characteristic curve,

Seems like CI was created for films that don't have a straight line.
Attachment 73767
• 08-31-2013, 09:49 PM
Rafal Lukawiecki
R Code for Computing CI
Mission accomplished, thanks to everyone, especially David for pointing out the system of non-linear equations based on the Pythagorean triangle relationship. If you run this, this is what you get:

Attachment 73774
And the data you feed into it comes from a text file that looks like this:

Attachment 73778

If you want to play with it, you need my code (attached) and a copy of R, which is a free programming language and an environment for statistics/numerical analysis, and which does nice plots. It runs on Windows, Macs, and Linux, get it from here if you feel geeky, or read about on Wikipedia. My code is in the attachment, all you need to do is to load it in R by using 'source("CI_plotter.R.txt")' having placed it in the current directory. If you open that file, you can see how to use it, I gave some examples. Let me know if anyone would like any pointers. I don't mind plotting your data, if you wish, to find the CIs—I suppose this won't be a very popular request, anyway.

The R code, which I wrote, works for the various curve data I fed into it. You need to give it a series of numbers representing your step tablet exposures (so from 0 on the left increasing towards the right) in a column called "He" and any number of columns containing your densitometer readings. R will plot the points and it will try fitting curves—using Bezier splines with 6 degrees of freedom by default. You can decrease that number for more smoothing (left-of-toe will look odd but calculations will work) or increase it, for less smoothing. You can also play with other smoothers if you uncomment the right lines in the code, including LOESS. In either case, the CI computations should work. I uses nleqslv, which is pretty much as close to SciPy fsolve, which David mentioned, as I could find today. The alternative which I have tested, multiroot (from rootSolve) was less forgiving of bad choices of the "starting point". This is a weakness of my code (I am sure one of many!). Sometimes, for some curves, it will not compute CI, it will display "NA" on the plot, and it will make a suggestion that you change the "starting.point". This is a parameter at the top of the program, which denotes the best guess of the x[1], x[2], and x[3] as per David's explanations, that is the rel log E values that are supposed to correspond to the projections onto the X axis of the 3 key CI determination points. In other words, those are: the centre of the two arcs, and the intersections of the 0.2 and the 2.2 arcs with x axis. I defaulted it to (0.9, 1, 2) by trial and error, but if it does not work for you, nudge them a bit either way, especially the first one. Anyone who would like to contribute a good way to guess those automatically, please let me know—I have tried interpolating them from a straight-line regression of the data points etc but that was worse than using my best manual guesses. Some other time I will add a function to plot the CI ~ dev time curve...

Ok, back to the darkroom tomorrow—I miss a low-contrast test in this data, will try a 4.5 min time to complete the exercise.
• 08-31-2013, 10:15 PM
Rafal Lukawiecki
Delta 100 4x5 DDX 1+4 Tank Extended Results
...and in case anyone were interested in the actual subject of my testing, Delta 100 4x5 developed in DDX 1+4 20C in a tank (CombiPlan) with fairly vigorous agitation (30 sec initially, followed by 3 inversions lasting about 5 seconds in total every 30 sec), I attach "extended" results. I obtained those by exposing two strips with the Eseco SL-2, both using green light. The second strip got three times the exposures of the first, but it does not actually amount to triple exposure, it seems, and I am in reciprocity territory, which this film seems to be good at. Undoubtedly, this is a questionable way of doing this, as I am numerically combining two separate tests into a single "extended" one, as if it came from one, longer step tablet—unlike in my previous post, where tests were "normal". Nonetheless, data seems OKish to my untrained eyes, and I welcome your feedback about this 9-stop range behaviour.
Attachment 73781
PS. To compute the first of the curves, I needed to adjust the "starting.points" to (0.95, 1, 2). Perhaps this should be the default.
• 08-31-2013, 10:56 PM
Bill Burk
Nice Rafal!

Now all you need is a Time/CI curve
• 09-01-2013, 03:07 AM
Rudeofus
Quote:

Originally Posted by ic-racer
Seems like CI was created for films that don't have a straight line.

The author who proposed CI did not have Rafal's jiggly spline curves in mind, though. Niederpruem et al. tried to account for toe shape and possible upswept/downswept curves, not for randomly swept spline segments that pointlessly try to fit noisy measurement data. It speaks volumes that Rafal's curve fit look, let's call it euphemistically "a bit odd" in the toe region. Oh well ...
• 09-01-2013, 04:54 AM
Rafal Lukawiecki
Indeed, Rudi—the upsweep towards less-than-none exposure looked humorous. :) Bear in mind, however, if I you increase the number of degrees of freedom on the Bezier spline to 7 or more, the toe looks just fine, yet the calculation still gets the CI—what we miss then is the smoothing that neatly takes care of the statistical measurement error. Having said that, I have to play, yet, with other types of splines, including log-influenced ones, which might have that "perfect" look.

But the next thing I plan to do is what Bill has suggested, that is the Time/CI curve. By the way, if anyone has a curve data series with their own, known CI, I'd be happy to check the algorithm against those numbers.
Show 40 post(s) from this thread on one page
Page 2 of 4 First 1234 Last