[Image-SIG] Removing specific range of colors from scanned image

Christopher Barker Chris.Barker at noaa.gov
Wed Apr 29 00:19:15 CEST 2009


Eduardo Ismael wrote:

> im = Image.open("C:\Scan_119.jpg")
> pixels = im.load()
> width, height = im.size
> 
> def distance (a, b):
>     return ((a[0]- b[0])** 2 + (a[1]- b[1])** 2 + (a[-1]- b[-1]) ** 2) 
> ** 0.5

I"m not sure there is any need to compute the sqrt here -- you can work 
in units of "distance" squared, instead, since you are doing thresholds.

> blue = (205, 241, 255) # a value I am presuming would be the average 
> blue in the image

That's not very blue!

>  Also, I don't think I followed your advice on
> "processing at the image level rather than by looping over pixels" Would 
> you correct it for me?

See the recent thread "Remove Noise from a National Weather Service 
Radar Image" to see how to convert to/from numpy arrays for this sort of 
thing. I prefer that approach to imagemath, but that may be because I am 
very familiar with numpy.


-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Image-SIG mailing list