Borkus McJorkus |
Hey, folks. I've got what seems like a simple request. Whether it's as simple to execute as it is to describe... well, we'll see.
What I'm looking for specifically is a filter that analyzes the pixels in an image consisting only of black and white (no gray!) pixels and replaces white pixels bordered by eight black pixels. In other words, let's consider three 3x3 pixel blocks, where "X" = a black pixel (RGB 0,0,0) and "O" = white pixel (RGB 255, 255, 255): XXX OXX XXX XOX XOX XXO XXX OXX OOX The filter I need would seek out the white pixels (0) with no adjacent white pixels and replace those solitary white pixels with black (X). So the result of applying this filter to those blocks above would result in: XXX OXX XXX XXX XOX XXO XXX OXX OOX The white pixel in the first block is turned black because it has no white neighbors. However, the white pixels in the second and third blocks remain unchanged. Make sense? Okay... so. How to do this? Thanks for your time. -- McJ |
|||
Posted: July 8, 2010 11:50 am | ||||
CorvusCroax
![]() |
Hi Borkus,
Filter Forge uses a 'sample based' architecture, which means that it doesn't deal with the actual pixels directly. (Instead it samples a point, and then decides what the color should be. This allows you to zoom and rotate smoothly, for examples.) That said, I think you could do it w/ offsets. Just figure out what the offset is, and use 8 if-then statements to find it. OR there's probably some clever scripting way to do it (but that's over my head at the moment!) ![]() |
|||
Posted: July 8, 2010 12:18 pm | ||||
tigerAspect |
Once we get the bitmap-based Script component it'll be as simple as a single for loop. (Probably)
I'm not up on LUA at the moment because all the effects I'd want to write are bitmap-based, otherwise I'd give you at least pseudo-code... |
|||
Posted: July 8, 2010 1:06 pm | ||||
Sphinx.
![]() |
This should be possible using the map script. The main "problem" is how to get from sampling coordinates to pixel coordinates (so you can get the precise pixel neighbours). We can find the sampling width of a pixel via SIZE variable (i.e. 1 / SIZE).
The attached filter should work as you describe.. Despeckle.ffxml |
|||
Posted: July 8, 2010 2:29 pm | ||||
CorvusCroax
![]() |
Here's my attempt at it. It's clunky an inelegant, but it sort of works. I say sort of b/c it gets most of the image right, but there are a few areas where it will mis-identify an area surrounded by 7 as being surrounded by all 8.
A neat side-discovery is at the bottom: a way to identify horizontal and vertical lines. Pixel Comparison.ffxml |
|||
Posted: July 8, 2010 3:09 pm | ||||
CorvusCroax
![]() |
Grr... what the @#$% is going on w/ the attachments?
![]() Props to Sphinx, unlike mine, his version actually works! ![]() |
|||
Posted: July 8, 2010 3:11 pm | ||||
Borkus McJorkus |
Oh, my! Sphinx, this rocks so hard! Just what I needed!
And Corvus, much thanks for your work, but I don't really understand how to use it. Any pointers? -- McJ |
|||
Posted: July 11, 2010 9:53 pm | ||||
CorvusCroax
![]() |
>And Corvus, much thanks for your work, but I don't really understand how to use it.
Not really: it shows how you'd construct a filter w/ offsets. The offset distance needs to be 1/pixel dimensions. Sphinx's is way better. |
|||
Posted: July 12, 2010 2:46 am | ||||
Borkus McJorkus |
Ah. Well, thanks anyhow. Appreciate the effort!
|
|||
Posted: July 12, 2010 6:47 am | ||||
Sphinx.
![]() |
Borkus I'm curious to what you are using this for? Are you despeckling something or what is going on?
|
|||
Posted: July 12, 2010 7:59 am | ||||
Totte
![]() |
@Sphinx: I think he is making a FF based "Game of Life"
- I never expected the Spanish inquisition |
|||
Posted: July 12, 2010 8:13 am | ||||
Borkus McJorkus |
No, no -- not doing any cellular automata applets. I've discovered a really neat misapplication of Alien Skin Software's Blow Up plugin.
Check it out. First we need an image consisting of only black and white pixels: ![]() |
|||
Posted: July 12, 2010 1:05 pm | ||||
Borkus McJorkus | ||||
Posted: July 12, 2010 1:09 pm | ||||
Borkus McJorkus |
That's some nice filigree! But look at the outskirts of the features:
![]() |
|||
Posted: July 12, 2010 1:11 pm | ||||
Borkus McJorkus |
Those blobs out lined in red are the offspring of some of those solitary pixels I needed killed. These solitary blobs are made up of the exact same configuration of grayscale pixels. Whether the blobs are white blobs on a black background, or black blobs on a white background, their repetition disrupts the wonderful irregularities that are created by a thriving ecosystem of pixels. THEY MUST BE DESTROYED!!!
So let's return to that fist image. We apply Sphinx's filter once, invert the image, apply the filter again, invert and we get: ![]() |
|||
Posted: July 12, 2010 1:27 pm | ||||
Borkus McJorkus | ||||
Posted: July 12, 2010 1:29 pm | ||||
Borkus McJorkus | ||||
Posted: July 12, 2010 1:43 pm | ||||
Borkus McJorkus |
Sphinx, could I beseech you to re-write the filter to find and erase those offenders?
If that's too much work, can you write a revision that erases the following: XXX XXXX X0X X00X X0X XXXX XXX And it would be lovely to have the filter find all of the solitary pixel/pixel blocks in a single pass (that is, in one application of the filter). But really, the filter as it exists now is good enough -- certainly it cuts down by several orders of magnitude the micro-management of removing details! Thanks again! |
|||
Posted: July 12, 2010 2:02 pm | ||||
CorvusCroax
![]() |
Sphinx, you might just number all the 8 adjacent pixels and wire them into on/off controls - that would make it generalized and less specific. Like so:
8 1 2 7 X 3 6 5 4 Then it could be a generic pixel adjacency seek and destroy component ![]() You could do all sorts of stuff with that: seek and destroy horizontal or diagonal lines for example. Borkus: have you used Perfectum, by Redfield? I also does some neat effects, similar to the alien skin filter. Works great for smoothing out JPEG badness. |
|||
Posted: July 12, 2010 5:45 pm | ||||
CorvusCroax
![]() |
Actually, ThreeDee made one of those already. (Using v1.0 components, I might add) |
|||
Posted: July 12, 2010 5:46 pm | ||||
Borkus McJorkus |
Yes, I really like Perfectum. But its results are generally wispy -- and what I'm doing with Blow Up is more... chunky? |
|||
Posted: July 12, 2010 6:09 pm |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,533 Posts
+38 new in 30 days!
15,348 Topics
+73 new in year!
32 unregistered users.