private static CommandLine getArgs(String[] args)
    {
        CommandLineParser clp = new BasicParser();

        Options options = new Options();
        options.addOption(new Option("P", "preview", false, "Show a pop up window of result"));
        options.addOption(new Option("S", "save", true, "Save image to file"));

        try
        {
            CommandLine cmd = clp.parse(options, args);

            if (cmd.getArgs().length == 0) throw new ParseException("No source image specified!");

            return cmd;
        }
        catch (ParseException e)
        {
            System.out.printf("%s%n%n", e);
            HelpFormatter formatter = new HelpFormatter();
            formatter.printUsage(new PrintWriter(System.out), HelpFormatter.DEFAULT_WIDTH, "Circle Detection", options);
            formatter.printHelp("[OPTIONS] <source image file>", options);
            System.exit(1);
            return null;
        }
    }