YOUR ACCOUNT

Login or Register to post new topics or replies
CorvusCroax
CorvusCroax

Posts: 1227
Filters: 18
So, recently I wanted to have pattern of stripes where each stripe was exactly 2 pixels wide. Is it possible to make an exact pixel dimension in FF?

(I assumed that I had to do it as an exact whole fraction of the image. I.e. If the image is 200 pixels, I'd have to do a setting which is 1% wide. If the image is 100 pixels, 2% wide, etc.)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Thanks for reminding me... I just had a thought this morning about how you could do that and I just tried it and the damn thing worked!

This is exploiting a possible error in how the motion blur is rendered and doing some other crazy stuff with it.

The enclosed filter offsets a line by pixel value regardless of image size. The background grid has been made with tiles. At default size (600x600 pixels) the smaller grid lines are 10 pixels apart. Moving the slider moves the line one pixel at a time.

If you then create a document of 300x300, the grid lines will be 5 pixels apart, but the line still moves one pixel at a time.

Same with 1200x1200 -- but you have to have the preview set to "Actual Size" for this to work or render the result -- the grid lines are 20 pixels apart, but the line moves one pixel at a time.

It even works when you change the global "Size, Pixels" until you go really small (under 100 pixels in this case).

---

As to how the filter itself works, here's the theory:

The motion blur, at very low settings, offset the image by one pixel. Thus, you can make a line that is 1 pixel wide in a document of any size by offsetting a thresholded edge by one pixel with motion blur and blending it with the original edge.

If you make this a white line on black background and motion blur this one line to cover the entire image, it seems to disappear, but really doesn't. It just gets smeared across the whole image. But because FF works at floating point precision, it really just becomes mixed with the background color. White is now mixed with the background black in the exact proportion of 1/(number of pixels in the image)!

Thus, this small number (the near-black image) can be used as the Percentage control for various operations, such as offset. And it will automatically give you a pixel-based Percentage.

It sounds crazy, maybe it even is crazy, but it works.

Pixel-based offset.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Here's another example, pixel-size-based circle.



Pixel-Based Circle Snippet.ffxml
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Previous snippet makes a circle with 0-100 pixels radius.

Here I replaced the size Slider with an Integer Slider, which extends the radius range to 0-1000, with 1 pixel increment, which makes more sense for this type of use:

Pixel-Based Circle Snippet 2.ffxml
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
ThreeDee wrote:
This is exploiting a possible error in how the motion blur is rendered and doing some other crazy stuff with it.


Back when I found the 1 Pixel Offset solution (see this thread), I asked FF about the motion blur issue - I got the reply that its not a bug, but rather a feature. So I guess we can rely on this feature being present in the future too smile;)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
Sphinx. wrote:
Back when I found the 1 Pixel Offset solution (see this thread), I asked FF about the motion blur issue - I got the reply that its not a bug, but rather a feature. So I guess we can rely on this feature being present in the future too Wink


Oh good, I was wondering whether this was going to be a current-version-only issue.

I'm trying to think of good uses for pixel-size-based effects. If you think of some, let me know.

Also, you can reverse engineer the size (in pixels) of the original image this way, even both width and height of a non-square image if you really want to, which may be useful for something -- one day I'll figure out for what.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Quote
ThreeDee wrote:
I'm trying to think of good uses for pixel-size-based effects. If you think of some, let me know.


Ok, most of this is old hat, but some of it might be worth exploring nonetheless.

Kernel/Window filtering:
- Edge detection (sobel, prewitt, canny etc)
- Image Gradients
- Laplacian filters
- Noise reduction
- Blur/Sharpen

Some of these require two pass processing with different kernels (one for rows and one for colums) and might even require additional pre- or postprocessing, which should be possible to do via intermediate cache blurs.
Some resources on the subject:
http://www.fho-emden.de/~hoffmann/gauss25092001.pdf
http://www-csl.csres.utexas.edu/users...eproc.html

Some other ideas:
- pixel patterns (stripes, lines, grids etc)
- cleartype like antialiasing
- custom antialiasing
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Hi Sphinx,

"Image gradients" and "Laplacian filters" don't say much to me -- could you explain what they are?

Pixel patterns seem the most immediately achievable idea. And would be useful for web design needs in particular, for you want to align things by pixel values.

I was thinking of making a grid that would allow you to set the grid frequency by pixel. Probably other basic patterns could use that capability -- such as checker. Definitely any place where you want to draw crisp lines that align to pixels or outlines that are a certain width in pixels.

Moreover, on web design, anything that would need to line up with type could use this kind of thing -- a horizontal line every 24 pixels, for instance, would line up with type of a certain point size.

And, actually, anything simulating a computer display or a program, for most stuff on the screen is drawn that way. (Which makes me wanna update my AutoCAD filter for improved realism -- proper pixel-based grids and guides, pixel-width outlines, etc.)

Now this makes me think of places where it would be useful to combine percentage-based and pixel-based: That might make it possible to do "rasterized vector art" -- think of some basic vector shapes with a pixel-value outline for instance. The sizes of the shapes could depend on the size of the image (resolution-independent or by percentage), while the outlines could be drawn by pixel value.

Well, this is all just theory for now. Might be other things that I'm not considering. The first one being whether it is possible to "snap to pixel" so that lines (in a grid for example) align to pixels instead of drawing in between two, which would make them blurry.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
I'm starting a thread on this over in the Creating Filters subforum.
  Details E-Mail

Join Our Community!

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!

Create an Account

Online Users Last minute:

18 unregistered users.