[Numpy-discussion] collecting the bluest pixels

Anne Archibald peridot.faceted@gmail....
Tue Oct 7 19:10:07 CDT 2008


2008/10/7 Christopher Barker <Chris.Barker@noaa.gov>:

> I wonder if the euclidian norm would make sense for this application:
>
> HowFarFromBlue = np.sqrt((255-image[...,BLU])**2 +
>                          image[...,GRN]**2 +
>                          image[...,RED]**2)
>
> smaller numbers would be bluest -- pure blue would be 0, pure red 360,
> etc...
>
> One thing I like about this is that your "blue" may not exactly be an
> RBG blue -- so you could see how "far" a given pixel was from any given
> color -- in your case, whatever your blue is. Then it would be something
> like:
>
> r, g, b = ref_color
>
> HowFarFromRefColor = np.sqrt((r - image[...,RED])**2 +
>                              (g - image[...,GRN])**2 +
>                              (b - image[...,BLU])**2
>                              )
>
>
> NOTE: I know nothing of image prcessing -- I"ll be there is are some
> standard ways to determine how "close" two colors are.

It's a tricky problem, but if you're serious about it you can use
Euclidean distance in the CIELUV colour space, or if you're really
serious Euclidean distance in CIELAB. Both probably overkill for this
project.

Anne


More information about the Numpy-discussion mailing list