php - Cleaning pixels from a map -


map

we have map, need use php take shades of blue out, percentages. problem is, of percentages in same color borders, , other times, percentages go border. need use image.

there not (afaik) easy ways.

the easiest way doesn't give results: separate channels , delete small components.

the result this:

enter image description here

as can see there few numbers , percent signs remaining because connected delimiting lines , deleting small components doesn't work them.

if need better job, should correlate image template of each number, , once identified, delete it.

here can see result of correlation number "2":

enter image description here

one wrong "2" identified, (see top left), more sophisticated approach may needed general procedure.

anyway, think these kind of manipulation beyond can expect k-12.

hth!

edit

as per request, detail first method.

you first separate 3 channels, , 3 images:

enter image description here

you keep third (the blue channel)

then need delete smaller components. there lot of methods that, easiest derived connectivity detection example in flood-fill algorithm, measure components without filling them.
basic (not optimized) idea travel every pixel in image , count how many pixels "connected" it. if there less specified number (threshold), delete whole set. image manipulation libraries have these functions implemented.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -