views:

151

answers:

3

i'd like to be able to calculate the 'mean brightest point' in a line of pixels. It's for a primitive 3D scanner.

for testing i simply stepped through the pixels and if the current pixel is brighter than the one before, the brightest point of that line will be set to the current pixel. This of course gives very jittery results throughout the image(s).

i'd like to get the 'average center of the brightness' instead, if that makes sense.

alt text

has to be a common thing, i'm simply lacking the right words for a google search.

+3  A: 

Calculate the intensity-weighted average of the offset.

Given your example's intensities (guessed) and offsets:

0  0  0  0  1  3  2  3  1  0  0  0  0  0
1  2  3  4  5  6  7  8  9 10 11 12 13 14

this would give you (5+3*6+2*7+3*8+9)/(1+3+2+3+1) = 7

David Schmitt
+1  A: 

You're looking for 1D Convolution which takes a filter with which you "convolve" the image. For example, you can use a Median filter (borrowing example from Wikipedia)

x = [2 80 6 3]
y[1] = Median[2 2 80] = 2
y[2] = Median[2 80 6] = Median[2 6 80] = 6
y[3] = Median[80 6 3] = Median[3 6 80] = 6
y[4] = Median[6 3 3] = Median[3 3 6] = 3
so
y = [2 6 6 3]

So here, the window size is 3 since you're looking at 3 pixels at a time and replacing the pixel around this window with the median. A window of 3 means, we look at the first pixel before and first pixel after the pixel we're currently evaluating, 5 would mean 2 pixels before and after, etc.

For a mean filter, you do the same thing except replace the pixel around the window with the average of all the values, i.e.

x = [2 80 6 3]
y[1] = Mean[2 2 80] = 28
y[2] = Mean[2 80 6] = 29.33
y[3] = Mean[80 6 3] = 29.667
y[4] = Mean[6 3 3] = 4
so
y = [28 29.33 29.667 4]

So for your problem, y[3] is the "mean brightest point".

Note how the borders are handled for y[1] (no pixels before it) and y[4] (no pixels after it)- this example "replicates" the pixel near the border. Therefore, we generally "pad" an image with replicated or constant borders, convolve the image and then remove those borders.

This is a standard operation which you'll find in many computational packages.

Jacob
A: 

your problem is like finding the longest sequence problem. once you are able to determine a sequence( the starting point and the length), the all that remains is finding the median, which is the central element. for finding the sequence, definition of bright and dark has to be present, either relative -> previous value or couple of previous values. absolute: a fixed threshold.

Egon