Switch to English Language Passer en langue française Omschakelen naar Nederlandse Taal Wechseln Sie zu deutschen Sprache Passa alla lingua italiana
Members: 70,224   Posts: 1,532,613   Online: 896
      
Page 1 of 4 1234 LastLast
Results 1 to 10 of 32
  1. #1
    Rafal Lukawiecki's Avatar
    Join Date
    Feb 2006
    Location
    Co. Wicklow, Ireland
    Shooter
    Multi Format
    Posts
    737

    Algorithm/Numerical Approach for Computing CI (Contrast Index)

    Recently I've been plotting my film test curves using R (sorry Bill), which I also use for smoothing them. I can calculate a myriad of gradients by getting a linear regression of any section of the fitted smooth curves, but I would like to code a procedure for calculating CI. I have used the hand-held technique, using the CI "ruler" with points marked off at 0.2 and 2.2 log E, and I think I understand the concept of the two concentric arcs described here. I have also seen discussions about automating curve-related plotting in several threads:


    While there is a lot of discussion about curve fitting, that is not one of my issues—I find that R fits a good enough curve for me. It usually does it using LOESS, and the fitted curve is a little odd just to the left of the point where the toe takes off, but this is not my concern, as the search for CI takes place further to the right of that point anyway, in the section where the curve seems to look good. Besides, I am sure it wouldn't be too hard to fix the wonky section if needed, after all the smooth fit uses splines.

    What I would like to ask for, please, is a pointer towards a suitable algorithm to use the just found curve to calculate the CI. I assume no weird curve shapes, and generally good inputs. If nothing can be found, then I will be resigned to writing a short loop, that "walks" the curve looking for the intersection of the 3 points on a straight line, first at x=FB+F, the other distant 0.2 and lying on the curve and the third, distant from the first 2.2, and also on the curve. But I am sure someone must have already coded that in a more elegant way than just doing a brute search along the curve.

    FYI, example of plots, I'd be happy to share the few lines of R code if anyone cares:
    Click image for larger version. 

Name:	Delta100_XTOL1-1_20C_10m_Tray DATA.png 
Views:	37 
Size:	65.9 KB 
ID:	73723Click image for larger version. 

Name:	Delta100_XTOL1-1_20C_10m_Tray SMOOTH.png 
Views:	39 
Size:	81.0 KB 
ID:	73722
    Many thanks.
    Rafal Lukawiecki
    See rafal.net | Read rafal.net/articles

  2. #2
    Bill Burk's Avatar
    Join Date
    Feb 2010
    Shooter
    4x5 Format
    Posts
    3,193
    Images
    46
    If I were programming this, I'd mimic what I already do. I'd treat curves as triangles and solve for intersections. I'd do the same when it came to curves (I would solve them as triangles). Since I already physically slide back and forth to find where the curve crosses the two arcs at the same angle, I'd do the same thing by recursively trying different points, until I get within 0.01 of the answer.

  3. #3
    cliveh's Avatar
    Join Date
    Oct 2010
    Shooter
    35mm RF
    Posts
    3,196
    Images
    344
    What on earth are you talking about?

    “The contemplation of things as they are, without error or confusion, without substitution or imposture, is in itself a nobler thing than a whole harvest of invention”

    Francis Bacon

  4. #4
    ic-racer's Avatar
    Join Date
    Feb 2007
    Location
    Midwest USA
    Shooter
    Multi Format
    Posts
    6,170
    Quote Originally Posted by Rafal Lukawiecki View Post
    a pointer towards a suitable algorithm to use the just found curve to calculate the CI.
    Do you know Microsoft EXCEL very well? I made two spreadsheets that could be modified to do what you want. One walks along the data points using an "IF-THEN" algorithm to find the correct points to create an ASA Triangle and find the 0.1 point.
    The other spreadsheet finds a few points on the curve to calculate "W" speed.
    Let me know if you want the spreadsheets. http://www.apug.org/forums/forum37/8...3g-speeds.html

    You would be free to experiment with them to make the needed changes to do a proper contrast index test, assuming this type of nomenclature makes any sense to you:
    =IF(AND(B8>=$E$35,B7<$E$35),(((C7-C8)/(B7-B8))),0)

    Click image for larger version. 

Name:	asatriangle.jpg 
Views:	12 
Size:	49.5 KB 
ID:	73727

    PS: your links above reminded me that I have changed my viewpoint on curve fitting. As may not be evident, my spreadsheets for EI and contrast calculations DON"T curve fit. I use simple triangulation to interpolate between the dots. That simple compromise has saved years of my life worrying about solving polynomial film curve equations for unknown variables and allowed me to take more photographs
    Last edited by ic-racer; 08-30-2013 at 09:22 PM. Click to view previous post history.

  5. #5
    Bill Burk's Avatar
    Join Date
    Feb 2010
    Shooter
    4x5 Format
    Posts
    3,193
    Images
    46
    Quote Originally Posted by cliveh View Post
    What on earth are you talking about?
    One measure of a film's characteristic curve is how steep it is. Gamma is one name for the slope of the curve. Think of 45-degrees as 1.0 because for every unit of exposure difference on the film you get one unit of density difference on the negative. 0.0 would be if you forgot to develop the film. Infinity would be where it goes instantly from clear to black. (Actually that is unlikely to ever happen, and a special meaning is given to the term: "Gamma Infinity" - which is the "most contrast you will ever get" in that developer, no matter how long you develop it, even if it's only 1.5 or 2.0.)

    Contrast Index is another term used to describe the slope of the curve. Contrast Index and Gamma just take two points on the curve and calculate the slope of them, they don't use curve fitting to describe the curve, it's just a straight-line between two points. The two differ from each other by the choice of endpoints you measure.

    Contrast Index uses a couple points spread out about as far apart as the part of the film you would normally use to print from. So it has the advantage of relating development to meet printing needs. Think of a protractor with an inner arc and an outer arc that you slide left and right until both arcs touch the line at the same angle (marked as slope to the center of the arcs). That's all Rafal wants to do, but he wants to do it with a computer program instead of on paper.


    Contrast Index Meter
    Here is a graph of Rafal's film tests, with "C" marks on each curve showing the two endpoints used to determine Contrast Index.

    The ASA triangle is also shown, it is very specific, and Rafal luckily hit it at 11 minutes. Note that even though the ASA triangle literally measures 0.62 slope by the points that define it, the Contrast Index of that same curve is 0.75 - significantly different...

    If I had a Normal scene, I would develop it 7 minutes because I aim for specific CI and for Normal I would aim for 0.62 CI. If I used Gamma instead, I might arrive at a different recommend developing time for Normal, and if I were to develop to ASA standard, I'd possibly develop 11 minutes.

    Last edited by Bill Burk; 08-30-2013 at 10:35 PM. Click to view previous post history. Reason: cross-platform link

  6. #6
    Rafal Lukawiecki's Avatar
    Join Date
    Feb 2006
    Location
    Co. Wicklow, Ireland
    Shooter
    Multi Format
    Posts
    737
    Thank you, Bill, for the suggestion of solving triangles. Dale, I'd love to have a look at those spreadsheets, I suppose I know enough Excel. I'd still plan to lift the logic into R, as I find it easier and faster to manage the data+code+plotting (ggplot2) in it for my film tests. I'd be happy to share the resulting code. Having said that, it seems like you're "walking" along the axis, similar what I thought of doing. I wonder if there is some more holistic approach (solving geometric inequalities?) that doesn't involve checking all the points, until a certain precision of the solution has been reached. Many thanks, everyone.
    Rafal Lukawiecki
    See rafal.net | Read rafal.net/articles

  7. #7

    Join Date
    Jul 2010
    Location
    Southern USA
    Shooter
    Multi Format
    Posts
    3,769
    Contrast Index is something that Kodak came up with to replace the traditional Gamma for their films. It never really caught on with other manufacturers.
    A rock pile ceases to be a rock pile the moment a single man contemplates it, bearing within him the image of a cathedral.

    ~Antoine de Saint-Exupery

  8. #8

    Join Date
    Feb 2009
    Shooter
    Med. Format RF
    Posts
    46
    Rafal,
    I am the fool who started the first of the APUG threads you listed, in which I suggested a simple mathematical function for fitting densitometric data. Suffice it to say that my methods were not instantly adopted by thousands of photographers, leading to the fame and fortune that I had imagined for myself. But, I have used that function to calculate the Kodak contrast index, and I think that I can suggest a general way to formulate the problem.

    The key thing that is needed is a relationship between the exposure and density, which is presumably based on your measured data. I used the function I described, with fit values for the 3 parameters that define that function. Having an analytical function makes things a bit easier, but one could also use a table of closely spaced points.

    Let's call the exposure values "x" and the density at a given value of x "D(x)". To use the Kodak definition, the exposure values should be given in log base 2 units (i.e. doublings or "stops"). The CI definition specifies 3 points that lie on a common line:

    1. A point on the baseline, where density - (base + fog) = 0.
    2. A point to the right of point 1 that lies on the curve and is 0.2 units away from point 1.
    3. A point to the right of point 2 that lies on the curve and is 2 units away from point 2.

    Call these points:
    x1,D(x1)
    x2,D(x2)
    x3,D(X3)

    From Pythagoras, the relationships among the points can be written as:

    (x2 - x1)^2 + (D(x2)-D(x1))^2 = 0.2^2
    (x3 - x2)^2 + (D(x3)-D(x2))^2 = 2.0^2
    (x3 - x1)^2 + (D(x3)-D(x1))^2 = 2.2^2

    This gives three equations in three unknowns. Once the values for the three x values are known, then the contrast index can be calculated from the slope of the line, using any pair of points:

    CI = (D(x3)-D(x2))/(x3-x2)

    Solving the equations has to be done numerically, i.e. iteratively, at least for my analytical function or a table of data points. This requires a starting guess for the three x values, but that isn't too difficult.

    I have done this in Python, using the optimize.fsolve function in the scipy package, but I'm sure that similar functionality can found in R.

    I hope that this is a bit of help. I'm happy to send you the Python code if that would be useful.

    David

  9. #9
    Bill Burk's Avatar
    Join Date
    Feb 2010
    Shooter
    4x5 Format
    Posts
    3,193
    Images
    46
    Hi David,

    The clinker in the formula is the point is not 0.2 units to the right...

    You have a baseline zero at B+F and two arcs, one with a radius of 0.2 units and the next with a radius of 2.2 units

    You look for a condition where the curve, zeroed at B+F, crosses the two arcs at the same angle.

  10. #10

    Join Date
    Feb 2009
    Shooter
    Med. Format RF
    Posts
    46
    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
    Last edited by dpgoldenberg; 08-30-2013 at 11:15 PM. Click to view previous post history.

Page 1 of 4 1234 LastLast


 

APUG PARTNERS EQUALLY FUNDING OUR COMMUNITY:



Contact Us  |  Support Us!  |  Advertise  |  Site Terms  |  Archive  —   Search  |  Mobile Device Access  |  RSS  |  Facebook  |  Linkedin