Consider the file input.jpg. I applied some tools to obtain a kind of binary image.Version: ImageMagick 7.0.4-2 Q16 x86_64 2017-01-02
Code: Select all
convert input.jpg -threshold 62% -morphology smooth Octagon bin-input.jpg
convert bin-input.jpg -define connected-components:area-threshold=60000 -define connected-components:keep=0 -define connected-components:verbose=false -define connected-components:mean-color=true -connected-components 4 id0-input.jpg
1. I have no idea why that black noise (small black portion) - this is not so important.
2. Since I'm going to do some computations using the black pixels, I decided to count how many black/white pixels there are. But the histogram shows not only B/W pixels, but also other gray levels.
Code: Select all
convert id0-input.jpg -define histogram:unique-colors=true -format %c histogram:info:-
1006292: ( 0, 0, 0) #000000 gray(0)
6350: ( 1, 1, 1) #010101 gray(1)
1784: ( 2, 2, 2) #020202 gray(2)
287: ( 3, 3, 3) #030303 gray(3)
40: ( 4, 4, 4) #040404 gray(4)
2: (250,250,250) #FAFAFA gray(250)
37: (251,251,251) #FBFBFB gray(251)
351: (252,252,252) #FCFCFC gray(252)
2061: (253,253,253) #FDFDFD gray(253)
7682: (254,254,254) #FEFEFE gray(254)
2953114: (255,255,255) #FFFFFF gray(255)
So I supposed that id0-input.jpg would contain only gray(0) and gray(255) pixels.-threshold value{%}
Apply simultaneous black/white threshold to the image.
Any pixel values (more specifically, those channels set using ‑channel) that exceed the specified threshold are reassigned the maximum channel value, while all other values are assigned the minimum.
4. What is happening in this case? How to make id0-input.jpg with only B/W pixels?