[SciPy-User] Most efficient way to eliminate or keep specified features from labeled image

Jason Roberts jason.roberts at duke.edu
Wed Apr 6 19:37:42 EDT 2011


> Basically, as input to choose, you pass an array that's as long as the  
> maximum label, and has ones at the indices of the labels you want to  
> keep, and zeros elsewhwere.

Zach,

Thanks for your suggestions! I did not realize that numpy.choose could be
used that way, and that approach works when there are 32 or less choices
(i.e. features to keep). Unfortunately numpy.choose is limited to 32 or less
and I often have hundreds.

Any other ideas? If not, I guess I will roll my own C or Cython function for
this. This "element-wise a in b" functionality seems like it would be common
enough that numpy would include it, but I guess not...

Best,
Jason




More information about the SciPy-User mailing list