How can I produce a fade-out or fade-in image effect?
Created Oct 3, 2000
Bill Day You can fade an image using a Java 2D convolve operation akin
to the edge detection discussed in my JavaWorld column,
"Image processing with Java 2D", at:
www.javaworld.com/jw-09-1998/jw-09-media.html
where x-1.0f>0 by some small amount, then you
apply this kernel by repeatedly convoluting the
image, you will see it fade out. You should be
able to fade back in by reversing this convolution
(1.0f-x>0) while checking each convoluted pixel's
RGB values against a copy of the original image
and clipping to the original's RGB values when you
reach them. If you are using grayscale images (R,
G, and B values are the same), it will be all the
easier, as you'll only need to check one value instead
of three for each pixel and pass.
www.javaworld.com/jw-09-1998/jw-09-media.html
The key thing to note is that if your kernel coefficients add up to more than one, you will darken the overall image. If you use a kernel like:
0.0f 0.0f 0.0f
0.0f x 0.0f
0.0f 0.0f 0.0f