Aligning (matching) colors (white balance, brightness) of two scenes based on reference object

What I am trying to do is to become able to compare with reasonable accuracy two real world fabric/textures (colorwise speaking) at two distinct locations. I can't move them into single place to observe them close to each other and in the same light conditions.

I was thinking about such a "protocol":

1. print some "test pattern" on white paper (reference object)
2. go into location 1 and take picture of object A close to reference object
3. go into location 2 and take picture of object B close to reference object
4. use some application/library/own code, to adjust colors on photo B so the reference object look similar (colorwise) to reference object on A
5. compare visually or statistically (programmatically) objects A and B

Does anyone know what is the easiest way to perform point 4? Is there an application for that step, or library or any other shortcut than implementing this on my own?

Or, maybe anyone knows application for the whole process, not particularly point 4, which could help me, or another protocol for performing such comparison?

Also please let me know it this can't be done this way, or rather, this is an oversimplified solution to provide "reasonable accuracy", and if so - why?

• Welcome Przemek B! Could you elaborate on what exactly the desired result of your proposed algorithm is? More precisely, what do you want to achieve, i.e. what do you mean when you say you want to compare fabrics?
– user9485
Commented Jul 16, 2020 at 18:29
• I would like to assess if two materials have similar hue (or "compatible") so i can mix them in a design and they don't look bad when composed. Commented Jul 17, 2020 at 22:16
• In this generality, I would expect this problem to be quite difficult to solve since you kind of want to "invert" the rendering equation. If you knew the scenes' geometries and lighting conditions sufficiently well, you could try to reverse engineer the material properties of the fabrics (without using a reference object), although this would likely need more work than you're willing to put into this problem. However, I also think that a software that solves step 4 approximately should exist somewhere. Maybe someone else here can provide you more useful feedback than me.
– user9485
Commented Jul 19, 2020 at 15:03
• Whats wrong with using grey cards? Why is it too limited? Its done in photography all the time. Anyway the problem is that a camera does not represent the spectum very well so if you want to be better you probably need a spectrometer Commented Jul 26, 2020 at 18:40
• @Chris yeah its called gray balance. Most image editors can do this. Commented Jul 26, 2020 at 18:41