12.07.2015 Views

Digital Image Processing (using Java)

Digital Image Processing (using Java)

Digital Image Processing (using Java)

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

(p.31)HSICalc.java: RGB → HIS(0~255) (0~1)LISTING 3.1 A program to convert RGB colours into values of hue, saturation andintensity. A conversion method from <strong>Java</strong>’s Color class is used.import java.awt.Color;import java.text.DecimalFormat;public class HSICalc {public static void main(String[] argv) {if (argv.length > 2) {int[] rgb = new int[3];for (int i = 0; i < 3; ++i)rgb[i] = Integer.parseInt(argv[i]);float[] values = Color.RGBtoHSB(rgb[0], rgb[1], rgb[2], null);String[] labels = { "H=", "S=", "I=" };DecimalFormat floatValue = new DecimalFormat("0.000");for (int i = 0; i < 3; ++i)System.out.println(labels[i] + floatValue.format(values[i]));}}}else {System.err.println("usage: java HSICalc ");System.exit(1);}- 5 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!