View Single Post
Old 13th April 2013, 00:27   #4  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
Quote:
Originally Posted by StainlessS View Post
Any suggestions for further band modes ? (EDIT, that can be calculated from a pixel count array)
I cannot say for sure whether this would be useful for my current project, but a "centered moving average" of rows might be a good way to smooth the mask.

General idea:

R = Moving average range

row(n)_average =
[row(n-R/2) + row(n-R/2 +1) + ... row(n) + ... row(n+R/2-1) + row(n+R/2)] / R

So, the general idea is to collect the min/max/median row values as you already have, but then replace one or more of these with the the calculated value for the current row, averaged with 1,2,3, ... of both the previous and following rows.

Centered moving averages work really well, but are a pain because you really want to stick with only odd numbers for R, and of course the values for the beginning and end rows cannot have a full range of averages, so you have to write extra code to deal with the end points (first row has no average; second row is averaged with the adjacent rows; and so on until you reach the R/2th row -- same for the last row).

I'm not sure this is going to make a difference for my current project, but you asked ...

Actually, as I think about it, this actually would help remove the need for all the blur functions, and even better, might tend to "feather" the edge of the mask.
johnmeyer is offline   Reply With Quote