|
Source: (largely custom); [HOLZ88:111-112], [SEUL00:52], [FOLE90:589-591]
While I was working on the oil paint filter, I tried many different versions of the MostFrequentColor() function. Since the oil paint filter algorithm itself was simple, by making slight changes to its helper function, I could easily get a multitude of different effects. Frosted glass is one of those ‘what if I tried this instead’ variations on oil paint.
The algorithm is exactly the same as oil paint. The difference lies in the helper function that is called. Here, instead of calling MostFrequentPixel(), a function called RandomColor() is called, and does just what it looks like it does…almost. The initial thought was to simply return one of the pixels in the ‘surrounding pixel range’ (based on the user defined radius) of the center pixel. In practice, that actually tended to create false edges in areas of high contrast and did not look very random at all. Instead, what I ended up doing was returning a ‘weighted random pixel’. That is, those pixels whose intensity appeared more often would have a greater chance of being chosen than if that pixel’s intensity was less common to the local area. This modification greatly enhanced the output.
The RandomColor() function is implemented by keeping an array of 256 integers, the index of the array represents the intensity; the value at that index represents how many pixels have that intensity. A random number is chosen between 1 and the total number of pixels in the local area. Beginning at intensity 1 and proceeding through the array, the function counts the number of pixels that had a particular intensity (the value of the array) until the count reaches the random number. This intensity is chosen and, in effect, gives more weight to colors with more common intensities. The average RGB value of pixels with that intensity is returned as the ‘weighted average’.
A ‘smoothness’ setting, as was done in the oil paint, was not implemented here, as it seems allowing a smaller of number of possible intensities would make the function more ‘random’ and less ‘weighted random’, which was the initial problem in the first place.
Real frosted glass would randomly disperse light coming through the glass. Thus this filter gets its name due to the random nature in which pixel values are calculated.

Frosted glass (medium frost)
Return to
the list of filters
|