# Create a copy of the image.
input_image_plus_copy = input_image_plus.duplicate()
image_processor_copy = input_image_plus_copy.getProcessor()

try:
    # Set binary options.
    options = jython_utils.get_binary_options(
        black_background=black_background)
    IJ.run(input_image_plus_copy, "Options...", options)

    # Convert image to binary if necessary.
    if not image_processor_copy.isBinary():
        IJ.run(input_image_plus_copy, "Make Binary", "")

    # Run AnalyzeSkeleton
    analyze_skeleton = AnalyzeSkeleton_()
    analyze_skeleton.setup("", input_image_plus_copy)
    if prune_cycle_method == 'none':
        prune_index = analyze_skeleton.NONE
    elif prune_cycle_method == 'shortest_branch':
        prune_index = analyze_skeleton.SHORTEST_BRANCH
    elif prune_cycle_method == 'lowest_intensity_voxel':
        prune_index = analyze_skeleton.LOWEST_INTENSITY_VOXEL
    elif prune_cycle_method == 'lowest_intensity_branch':
        prune_index = analyze_skeleton.LOWEST_INTENSITY_BRANCH
    result = analyze_skeleton.run(prune_index, prune_ends,
                                  calculate_largest_shortest_path,
                                  input_image_plus_copy, True, True)
    # Save the results.
    save(result, output, show_detailed_info, calculate_largest_shortest_path)
except Exception, e: