Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29111
| From | Knute Johnson <eternal@knutejohnson.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Sepia tone image filter for Java |
| Date | 2014-07-15 10:22 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <lq3nvn$hpl$1@dont-email.me> (permalink) |
| References | (1 earlier) <ae206f7a-9d4b-44f2-9577-1def95831b53@googlegroups.com> <ln77s9lrnc8anip3l5na1juuqc6ru3j71g@4ax.com> <9qcxpjcscbfw$.mnsqslm70xg3.dlg@40tude.net> <r92as9lggp23l68v4ag7o6bkiibdvqcg80@4ax.com> <lq3nbd$d96$1@dont-email.me> |
I like these scale factors even better
float[] factor = new float[] { 1.35f,1f,.7f };
On 7/15/2014 10:11, Knute Johnson wrote:
> On 7/15/2014 03:59, Roedy Green wrote:
>> On Mon, 14 Jul 2014 11:24:10 +0200, Joerg Meier <joergmmeier@arcor.de>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> Yes, that is typically what happens when you darken blue. On a computer
>>> screen, "darken" means less of a colour ;)
>>
>> Of course. I was thinking in terms of paint, where adding more blue
>> paint would be "darkening" the blue.
>>
>
> A sepia tone filter is trickier than I thought. I need to compare the
> results from this code with the sepia filter in JavaFX.
>
> import java.awt.*;
> import java.awt.color.*;
> import java.awt.image.*;
> import java.net.*;
> import javax.imageio.*;
> import javax.swing.*;
>
> public class test0 extends JPanel {
> private BufferedImage orig,sepia;
>
> public test0() {
> try {
> URL url = new URL(
> "http://rabbitbrush.frazmtn.com/xlsjacksonhole.jpg");
> orig = ImageIO.read(url);
> setPreferredSize(new
> Dimension(orig.getWidth(),orig.getHeight()*2));
>
> // convert to grayscale and back to RGB
> ColorSpace imgCS = orig.getColorModel().getColorSpace();
> ColorSpace grayCS =
> ColorSpace.getInstance(ColorSpace.CS_GRAY);
> ColorConvertOp cop = new ColorConvertOp(imgCS,grayCS,null);
> sepia = cop.filter(orig,null);
> cop = new ColorConvertOp(grayCS,imgCS,null);
> sepia = cop.filter(sepia,null);
>
> // slightly enhance the red, slightly reduce the green and
> // remove half the blue
> float[] factor = new float[] { 1.1f,.9f,.5f };
> float[] offset = new float[] { 0f,0f,0f };
> RescaleOp rop = new RescaleOp(factor,offset,null);
> sepia = rop.filter(sepia,null);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> public void paintComponent(Graphics g2d) {
> g2d.drawImage(orig,0,0,null);
> g2d.drawImage(sepia,0,sepia.getHeight(),null);
> }
>
> public static void main(String... args) {
> EventQueue.invokeLater(new Runnable() {
> public void run() {
> JFrame f = new JFrame("test0");
> f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
> f.add(new test0(),BorderLayout.CENTER);
> f.pack();
> f.setVisible(true);
> }
> });
> }
> }
>
>
--
Knute Johnson
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Sepia tone image filter for Java jf498989@gmail.com - 2014-07-12 13:49 -0700
Re: Sepia tone image filter for Java Roedy Green <see_website@mindprod.com.invalid> - 2014-07-14 02:12 -0700
Re: Sepia tone image filter for Java Joerg Meier <joergmmeier@arcor.de> - 2014-07-14 11:24 +0200
Re: Sepia tone image filter for Java Roedy Green <see_website@mindprod.com.invalid> - 2014-07-15 03:59 -0700
Re: Sepia tone image filter for Java Knute Johnson <eternal@knutejohnson.com> - 2014-07-15 10:11 -0700
Re: Sepia tone image filter for Java Knute Johnson <eternal@knutejohnson.com> - 2014-07-15 10:22 -0700
Re: Sepia tone image filter for Java Knute Johnson <eternal@knutejohnson.com> - 2014-07-17 18:53 -0700
Re: Sepia tone image filter for Java Jeff Higgins <jeff@invalid.invalid> - 2014-07-19 08:18 -0400
csiph-web