'Projects/얼굴특징점추출'에 해당되는 글 2건

  1. 2010.12.19 java 투명도(alpha)조절
  2. 2010.07.04 tip : YCbCr to RGB, RGB to YCbCr
posted by bluelimn 2010.12.19 15:33

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class AlphaImage implements AdjustmentListener
{
 private JFrame frame;
 private Canvas canvas;
 private JScrollBar jsp;
 private Image image;
 private AlphaComposite alphaComposite;
 private Label label;
 
 public AlphaImage()
 {
  image = Toolkit.getDefaultToolkit().getImage("1.jpg"); //원하는 이미지
  frame = new JFrame();
 
  jsp = new JScrollBar();
  jsp.addAdjustmentListener(this);
  jsp.setMaximum(265);
  jsp.setMinimum(0);
  image = Toolkit.getDefaultToolkit().getImage("1.jpg");
  label = new Label("alpha = " + jsp.getValue());
 
  canvas = new Canvas(){
   public void paint(Graphics g)
   {   
    alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)jsp.getValue()/255); //alpha값
    Graphics2D g2 = (Graphics2D)g;
    g2.setComposite(alphaComposite);
    g2.drawImage(image, 0, 0, this);   
   }
  };
  frame.add(canvas, BorderLayout.CENTER);
  frame.add(jsp, BorderLayout.EAST);
  frame.add(label, BorderLayout.SOUTH);
  frame.setSize(300,300);
  frame.setVisible(true);
 }

 public void adjustmentValueChanged(AdjustmentEvent e)
 {
 
  if(label != null)
   label.setText("alpha = " + jsp.getValue());
  if(canvas != null)
   canvas.repaint();
 }

 public static void main(String[] args)
 {
  new AlphaImage();
 }
}


'Projects > 얼굴특징점추출' 카테고리의 다른 글

java 투명도(alpha)조절  (0) 2010.12.19
tip : YCbCr to RGB, RGB to YCbCr  (0) 2010.07.04
posted by bluelimn 2010.07.04 23:47

RGB to YCbCr

Y = 0.299R + 0.587G + 0.114B

Cb = 0.564(B - Y)

Cr = 0.713(R - Y)


YCbCr to RGB

B = Y + 1.772Cb

G = Y - 0.344Cb - 0.714Cr

R = Y + 1.402Cr

'Projects > 얼굴특징점추출' 카테고리의 다른 글

java 투명도(alpha)조절  (0) 2010.12.19
tip : YCbCr to RGB, RGB to YCbCr  (0) 2010.07.04

티스토리 툴바