I crop four areas, from the last four chart samples (20, 40, 80 and 160 ppm), and scale each to a single pixel, and append these side by side.
Then I make a sample from the lightest part of the test tube, and scale that to the same size.
Take the difference of these 4x1 images, and find the RMS of the colour channels. Write the result as text.
Windows BAT syntax:
Code: Select all
convert ^
tubeCols.jpg +write mpr:TC -delete 0 ^
( mpr:TC -crop 400x200+1300+1500 +repage ) ^
( mpr:TC -crop 400x200+1300+1920 +repage ) ^
( mpr:TC -crop 400x200+1300+2330 +repage ) ^
( mpr:TC -crop 400x200+1300+2730 +repage ) ^
-scale "1x1^!" ^
+append ^
( mpr:TC -crop 100x700+870+1700 +repage -scale "4x1^!" ) ^
-compose Difference -composite ^
-grayscale RMS ^
txt:
The result is:
Code: Select all
# ImageMagick pixel enumeration: 4,1,65535,gray
0,0: (17347,17347,17347) #434343 gray(67)
1,0: (10409,10409,10409) #292929 gray(41)
2,0: (10251,10251,10251) #282828 gray(40)
3,0: (16932,16932,16932) #424242 gray(66)
The third pixel has the lowest (darkest) gray, so that is the best match, ie 80ppm, by this measure.
However, if we use Lab colorspace instead of sRGB:
Code: Select all
convert ^
tubeCols.jpg -colorspace Lab +write mpr:TC -delete 0 ^
( mpr:TC -crop 400x200+1300+1500 +repage ) ^
( mpr:TC -crop 400x200+1300+1920 +repage ) ^
( mpr:TC -crop 400x200+1300+2330 +repage ) ^
( mpr:TC -crop 400x200+1300+2730 +repage ) ^
-scale "1x1^!" ^
+append ^
( mpr:TC -crop 100x700+870+1700 +repage -scale "4x1^!" ) ^
-compose Difference -composite ^
-grayscale RMS ^
txt:
Code: Select all
# ImageMagick pixel enumeration: 4,1,65535,gray
0,0: (6872,6872,6872) #1B1B1B gray(27)
1,0: (4100,4100,4100) #101010 gray(16)
2,0: (4365,4365,4365) #111111 gray(17)
3,0: (10497,10497,10497) #292929 gray(41)
Here, the second sample is closest.
Perhaps we should use Lab but exclude Lightness from the calculation:
Code: Select all
convert ^
tubeCols.jpg -colorspace Lab ^
-channel R -evaluate set 50%% +channel ^
+write mpr:TC -delete 0 ^
( mpr:TC -crop 400x200+1300+1500 +repage ) ^
( mpr:TC -crop 400x200+1300+1920 +repage ) ^
( mpr:TC -crop 400x200+1300+2330 +repage ) ^
( mpr:TC -crop 400x200+1300+2730 +repage ) ^
-scale "1x1^!" ^
+append ^
+write info: ^
( mpr:TC -crop 100x700+870+1700 +repage -scale "4x1^!" ) ^
-compose Difference -composite ^
-grayscale RMS ^
txt:
Code: Select all
# ImageMagick pixel enumeration: 4,1,65535,
0,0: (6416,6416,6416) #191919 gray(25)
1,0: (3616,3616,3616) #0E0E0E gray(14)
2,0: (3848,3848,3848) #0F0F0F gray(15)
3,0: (6994,6994,6994) #1B1B1B gray(27)
Again, the second sample is the closest.
As you can see, the result depends on what colour model we choose to measure the "closeness" of the colour patches.
If the elements are in the same positions in all photos, the same code will work.