One weakness of HSB etc is that the Hue channel is all over the place at low saturations. The Lab colorspace doesn't have this problem.
Code: Select all
"%IMG%convert" ^
bike.jpg ^
-colorspace Lab ^
-separate ^
-auto-level ^
b.png
If we magnify b-1.png by 400%, we can admire the 16x16 jpeg artefacts. Horrible! I hate working from jpeg originals. Still, b-1.png and b-2.png look useful. Let's negate one and overlay:
Code: Select all
"%IMG%convert" ^
( b-1.png -negate ) ^
b-2.png ^
-compose Overlay -composite ^
-threshold 60%% ^
bc.png
I can't find a threshold that captures all the detail (spokes, brake cables, mudguard stays) without also catching the backdrop. So let's find the detail with a different method, using standard deviation:
Code: Select all
"%IMG682%convert" ^
bike.jpg ^
-modulate 100,0,100 ^
( -clone 0 -statistic StandardDeviation 2x2 -auto-level ) ^
( -clone 0 -statistic StandardDeviation 5x5 -auto-level ) ^
( -clone 0 -statistic StandardDeviation 10x10 -auto-level ) ^
-delete 0 ^
( -clone 0 -clone 1 -compose Screen -composite ) ^
-compose Screen -composite ^
-negate ^
bikeSDa.png
... and combine these two masks ...
Code: Select all
"%IMG%convert" ^
bikeSDa.png ^
bc.png ^
-compose Multiply -composite ^
bcm.png
Yeah, that's not too bad. It shows the 16x16 jpeg artefacts, and suffers an edge problem. It doesn't find the white frame near the bottom bracket (near the pedals), where the frame has reflected the backdrop and blends into it.
If we use this mask to overlay the girl+bike against a red background...
Code: Select all
"%IMG%convert" ^
-size 640x480 xc:Red ^
( bike.jpg bcm.png -compose Copy_Opacity -composite ) ^
-compose Over -composite ^
bikeRed.png
... we see small problems at the girl's belt and throat, and the wheel rim. Further work could fix these. I think the bike frame at the bottom bracket needs manual intervention.
https://www.dropbox.com/s/0ap4orgzucpwb34/bikeRed.png
Incidentally, does the cyclist know her chain has fallen off?