Cleanning B&W scan
Posted: 2017-08-27T05:07:41-07:00
Hi forum people!
I am a newbie with IM so, thank you for your patience.
I spend 2 days to understand the principle reading doc and trying but this is hard and I struggle to reach my target.
Version: ImageMagick 6.9.3-0 Q16 x86_64 2017-03-11
I need to clean B&W scan (music sheet), I mean remove (change to white) all black shapes too big.
I want to remove (change to white) all shapes with size equal or smaller than 5x5. That means all shapes bigger than 5 pix in 1 dimension should be kept as it is.
Good if the size (5x5) is a parameter that I can change.
So far I did the following, not the easy way but it works for some shapes. It treats so far only to 3x3 black shape. However I don't know how to remove 3x3 square shapes and some other.
Could you help me, in a clear way, I mean I need the command.
Many thanks
I am a newbie with IM so, thank you for your patience.
I spend 2 days to understand the principle reading doc and trying but this is hard and I struggle to reach my target.
Version: ImageMagick 6.9.3-0 Q16 x86_64 2017-03-11
I need to clean B&W scan (music sheet), I mean remove (change to white) all black shapes too big.
I want to remove (change to white) all shapes with size equal or smaller than 5x5. That means all shapes bigger than 5 pix in 1 dimension should be kept as it is.
Good if the size (5x5) is a parameter that I can change.
So far I did the following, not the easy way but it works for some shapes. It treats so far only to 3x3 black shape. However I don't know how to remove 3x3 square shapes and some other.
Could you help me, in a clear way, I mean I need the command.
Many thanks
Code: Select all
convert in.png -verbose \
-morphology Thicken '5x5:1,1,1,1,1, 1,0,0,0,1, 1,0,0,0,1, 1,0,0,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,1,1, 1,1,0,1,1, 1,1,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,0,1, 1,1,1,1,1, 1,0,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,1,1, 1,0,0,1,1, 1,1,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,0,1, 1,1,0,1,1, 1,0,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,0,0,1, 1,1,0,0,1, 1,1,0,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,0,0,1, 1,1,0,0,1, 1,1,1,1,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,1,1, 1,0,1,1,1, 1,1,0,1,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,0,1,1, 1,0,1,1,1, 1,0,1,1,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,1,1, 1,1,0,1,1, 1,0,1,1,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,1,0,1,1, 1,1,0,1,1, 1,1,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,1,0,1,1, 1,1,0,1,1, 1,0,1,1,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,1,0,1,1, 1,1,0,1,1, 1,0,1,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,1,0,1,1, 1,1,0,1,1, 1,0,0,0,1, 1,1,1,1,1' \
-morphology Thicken '5x5>:1,1,1,1,1, 1,0,1,1,1, 1,0,1,1,1, 1,0,0,0,1, 1,1,1,1,1' \
-morphology Thicken '3x5:1,1,1, 1,0,1, 1,0,1, 1,0,1, 1,1,1' \
-morphology Thicken '5x3:1,1,1,1,1, 1,0,0,0,1, 1,1,1,1,1' \
-morphology Thicken '3x4:1,1,1, 1,0,1, 1,0,1, 1,1,1' \
-morphology Thicken '4x3:1,1,1,1, 1,0,0,1, 1,1,1,1' \
-morphology Thicken '4x4:1,1,1,1, 1,0,0,1, 1,0,0,1, 1,1,1,1' \
-morphology Thicken '4x4>:1,1,1,1, 1,0,0,1, 1,0,1,1, 1,1,1,1' \
-morphology Thicken '4x4>:1,1,1,1, 1,0,1,1, 1,1,0,1, 1,1,1,1' \
-morphology Thicken '3x3:1,1,1, 1,0,1, 1,1,1' \
out.png