Hey Guys,
I've got it! Mucho thanks for the very cool numpy example from Chris and of
course to everyone else for the assistance. I can now add this code to a
program that upsamples these images so they look better when plotted on a
GIS map. I realize that I'm technically destroying data by blasting pixels
from the image, but sometimes it's better to have a pretty presentation!
You can try this code by grabbing a radar image from the source server:
http://radar.weather.gov/ridge/RadarImg/N0Z/
##############################################
from PIL import Image
import numpy as np
#Open the raw radar image
raw_image = Image.open("ABR_N0Z_0.gif")
# make an array out of the image:
a = np.asarray(raw_image).copy()
# The noise colors are index 0,7,8 in the palette
# I used IrfanView to determine this
noise_colors = [0,7,8]
# white is index 15
white = 15
# Replace the noise colors with white
for color in noise_colors:
a[a==color] = white
# Build the clean image from the array
im1 = Image.fromarray(a, mode='P')
# Give it the original palette
im1.putpalette(palette)
# Save it out
im1.save("clean_image.gif")
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig