[Numpy-discussion] collecting the bluest pixels
Christopher Barker
Chris.Barker@noaa....
Tue Oct 7 15:53:44 CDT 2008
paul taney wrote:
> Thank you Stefan and Anne for such quick replies.
>
> I am writing a gimp plugin
cool!
> I get a divide by zero error on
>
> np.divide(image[...,BLU], image[...,GRN], B)
>
> ...and I dont understand this well enough to diagnose. Any ideas?
you're dividing the value of Blue by the value of green, so if there is
zero green, yes, you will get a divide by zero error.
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.
-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@noaa.gov
More information about the Numpy-discussion
mailing list