3

I've got this BufferedImage object that's guaranteed to contain only one color. I'm using it to display a sample image to show size, shape & hardness of a brush in a painting tool. I've tried several different blur implementations for hardness... the latest, that seems to work fairly well is this Stack Filter written by Romain Guy.

I've got 2 problems.

  1. Faster on 1 channel than 4?: None of the blur filters I've tried seem to be quite fast enough... I realize this question has been asked before (and I'm not quite ready to try pulling in FFTW from C), but I'm wondering if there's a way to perform the blur using ONLY the alpha channel bits? The image only contains one color, so none of the other bits will change across points anyway and my thought is that this would cut the number of calculations for the blur to about 25% of the whole blur operation and I figure that's likely to result in a noticeable improvement in performance? I've not been able to find any information about this being tried via web search.

  2. Eliminating the Dark Halo: Every time I try a different blur algorithm I end up having to rewrite it to get rid of the dark shadow around the shape caused by blurring in "black" from colorless pixels where nothing has been painted in yet. I've read about this and I'm using (as far as I know) INT_ARGB_PRE image types, which I remember reading as a solution to this problem. Am I missing something in that solution? Do I need to preformat the image in some way to make it interpret all the empty pixels as white instead of black?

Thanks!

Sam Dealey
  • 371
  • 4
  • 10

1 Answers1

3

You may find this interesting: http://www.jhlabs.com/ip/blurring.html

The dark halo issue is discussed, all source code is available as as far as I can recall, it only uses standard Java SE stuff.

G_H
  • 11,739
  • 3
  • 38
  • 82
  • Thanks G. Yeah, John's site was where I read about using int_argb_pre -- at least that's what I got from reading his brief comment about it... but his explanation was pretty terse so I'm pretty sure I'm missing a step. – Sam Dealey Aug 19 '11 at 09:06
  • Maybe the code can clarify a bit. I've been experimenting with convolutions, but not quite enough to have a direct answer ready for you. I do suppose that if you eliminate the halo through alpha premultiplying, you lose the possibility of only blurring the alpha channel. Although I'm not certain that would work anyway. Exactly how fast does the blur need to be? Maybe you can pre-render some stuff and cache it? – G_H Aug 22 '11 at 10:41
  • Well I'm not sure how fast it really needs to be... I'm early in the development of this application and I know that the brush gets pretty sticky when I turn the hardness down, so what I'm doing now isn't working very well... it needs to be relatively smooth to the user... I'm starting to think that I might postpone the blur until after the stroke is complete. I'm sure the users would prefer it happen while they're drawing, but since they've got an undo history, blurring after the fact should be okay. And I've got a theory about a way to speed up the blur, but haven't tried it yet. Thanks, G. – Sam Dealey Sep 14 '11 at 16:15