[Tutor] Masked arrays & scipy.ndimage.<filters>

Koen De Munter koendemunter at hotmail.com
Fri Jun 1 09:42:15 CEST 2012


Dear tutors,

Given an image, I want to generate another image with the mean values of
 the pixels in their neighbourhood, thereby ignoring some of the 
neighbouring pixels (e.g. the padded boundary). I hoped I could use 
masked arrays for that, but apparently, this does not work.

--
def fnc(buffer)
     return numpy.mean(buffer)

mean = scipy.ndimage.generic_filter(masked_array, fnc, footprint = f, mode = 'constant', cval = 0.0)
--

Is there a way to get around this issue, or do I have to accept the filter function can not handle masked arrays?

Thanks in advance!
Sincerely,
Koen
 		 	   		  


More information about the Tutor mailing list