I have some progress to report, and some preliminary conclusions.
I modified the Matlab program to calculate the medians of each patch individually, rather than passing a median filter over the whole image. That reduced the run times from 8 hours to 5 seconds, and most of that time was file reading; the actual media calculations take a little over a second. The results were the same to 9 decimal places. I looked at the results. I'm pretty sure I have successfully dealt with the random noise, as evidenced by scatter plots that are smooth rather then jittery. However, the graph of the statistics is barely changed from the one I posted above. This means that I have not dealt with capture variation well.
In the past, I've handled capture variation by averaging multiple exposures. I am loath to do that here, since the image manipulations are already fairly labor intensive. Instead, I plan to focus on working with synthetic images. Since they are almost noiseless (maybe a little LSB toggling in integer TIFFs), I'll have fewer images to deal with than if I have to do averaging. In addition, I will be able to precisely place the colors in CIELab., which you can't do with a real camera, due to the nature of the filters in the CFA. These errors can't be entirely calibrated out with camera profiles, since the CFA's spectral responses are not a 3x3 matrix multiply away from those of the human cone cells.
In order to present LR with images that it will process as it does raw files, I will have to learn how to create floating-point TIFFs (thank you, Eric, for the pointer here). I have discovered a TIFF object in Matlab that lets you do things that the image file writing function, imwrite, won't normally let you do, including, reportedly, writing 32-bit floating point TIFFs. However, before I do that, I will have to learn a lot about TIFF tags and the LabTIFF library.
The discovery that there are at least two image-processing pipelines in Lightroom (Eric, are there more than two?) makes me more motivated than ever to devise techniques to discover what LR is doing in various circumstances. Photoshop is not completely open about its image processing algorithms, but at least you can turn on or off each layer individually and see the effects. In LR, all the image processing takes place inside a black box, and the user can't see inside that box.