Tada, new version. (0.4). Again on github.
I've added something on top of the equalization thingie, a histogram matching. It helps preserve the contrast, but reintroduces a few artifacts, so on top of this histogram matching, I have added a smoothing parameter for this histogram matching. The defaults were set to look good on the picture I linked, but different scenes may need more or less smoothing of the histogram.
And, I regret to say it, there's some kind of bug in the smoothing algorithm, because on some occasions, it will just completely ruin the result for no discernable reason. I think it's a flaw in my programming logic, will have to figure it out. In short, currently it's a kind of playing around to get decent results, but in some cases you can already get really nice results.
To help you decide if the match is going to be messed up by the smoothing, I autogenerate 3 files in the program folder showing the outcome of the histogram smoothing. If it didn't go well, you can tell by those 3 pngs very quickly without having to save out and try the 3d lut.
In short, the result now can be anything between atrocious to nearly perfect, depending on the material you feed it and the settings used. The whole equalization and histogram matching and histogram smoothing should only be used with problematic scenes to begin with tho, unless I can get it to work a bit more reliably in the future, so I recommend disabling it by default. Currently it's on by default.
In terms of generalizing ... it's still not great, but I think the best improvement there will come from a function to smooth the resulting LUT before saving it. Creating a LUT with this and smoothing it in 3D LUT Creator already gives beautiful or at least very useful results most of the time. Without smoothing, it is good enough to at least comfortably cover a larger frame of the stuff that was matched by now. So say you match to a Pan & Scan version, it should be good enough to cover the whole frame unless something crazy happens in another part of the frame.
The main strength of this so far is color fidelity when it comes to small details, which DrDre's tool can easily miss in my experience. For example if there's a small tiny item in the image that should have a particular color but most of the image is going in a different direction, DrDre will struggle to give it the right tone, but this tool should give pretty good results unless there are other issues with the frames.
As always, all feedback is appreciated.