Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have two sets of data, and I want to know if the second set is sufficiently different from the first to be considered different.

More specifically, I have a sample set A from a number of pixels in the vicinity of point X in an image, and another sample B of pixels in the vicinity of point Y in the same image.

I want to know if point X and point Y could be part of the same object in the image (based on color values). For example, if A and B are both mostly blue then the answer is yes, but if A is red and pink and B is blue then the answer is no.

My only idea so far (based on vague memories of a statistics class I took years ago) is to calculate the standard deviation in A and B, and from that calculate a threshold that gives you 95% certainty, and see if they are within a certain distance of each other. Is this correct?

Otherwise, what's the best way to do this?

share|improve this question
What sort of data you have? It seems like the Kolmogorov-Smirnov test could be appropriate here. It is used to check wether two samples come from the same distribution. It can be easily calculated in R with the command ks.test. – user10525 May 9 '12 at 23:33
They are pixels from an image. More specifically, I have a border detection algorithm, but I want to verify borders by checking that pixels on opposite sides of the border are "different". – CaptainCodeman May 9 '12 at 23:52
I'm used to seeing color defined by values on 3 different variables. Are you talking about color as something that can be defined by a value on a single variable? – rolando2 May 10 '12 at 3:01
No, I'm using all 3 RGB values. So basically, a color is a point in 3D space. – CaptainCodeman May 10 '12 at 10:44
Well, more accurately, in some parts (e.g. border detection) I'm effectively using one variable: I find the mean, and then use the distance from the mean as a one-dimensional variable. – CaptainCodeman May 10 '12 at 11:03

1 Answer

up vote 1 down vote accepted

You want to compare the distributions of the samples. If the border is distinct, using a single hue dimension with a Kolmogorov-Smirnov test might suffice. If hue alone does not provide enough separation you'll have to add another dimension. If you want to stick to chromaticity (color without the brightness dimension), I would suggest the a* and b* color-opponent dimensions in the CIELAB color model. With two dimensions you can apply this KS test. If you want to go whole hog and use all three dimensions, look here.

share|improve this answer
Interesting, but I'm curious: why should the algorithm be different when you have more dimensions? I've just been assuming that a color is a point in 3D space (by RGB), and measure distances accordingly. Is there an advantage to taking it down to 1 or 2 dimensions? – CaptainCodeman May 10 '12 at 10:43
When you have a small sample, they will be sparse in high dimensions so obtaining a meaningful, accurate histogram will be more difficult. – Emre May 10 '12 at 17:49
Thanks a lot Emre, I've looked into these, good stuff indeed. – CaptainCodeman May 11 '12 at 11:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.