 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
20 "Usage: bcolour [options] input.img output.img",
21 "---------------------------------------------",
22 "Generates nice colour images.",
23 "Only image file formats capable of handling RGB can be used for output",
24 " (TIFF, PNG, JPEG).",
27 "-invert Invert image.",
28 "-red -4.5,88.3 Convert a grayscale range to red.",
29 "-green -4.5,88.3 Convert a grayscale range to green.",
30 "-blue -4.5,88.3 Convert a grayscale range to blue.",
31 "-spectrum 1,22.4 Convert a grayscale range to a spectral colour scale.",
32 "-rwb 0,56,167,245 Convert a grayscale range to a red, white and blue image.",
33 "-phases Colour the phases in a polar map or complex transform.",
34 "-intensities Calculates the intensities without colours.",
35 "-pure Calculates pure colours without intensity.",
36 "-alpha Add an alpha (transparency) channel.",
37 "-noalpha Remove the alpha (transparency) channel.",
38 "-torgb Convert grayscale or CMYK to RGB.",
39 "-tocmyk Convert grayscale or RGB to CMYK.",
40 "-split Split the channels into individual images.",
41 "-combine 3 Combine channels from individual images.",
44 "-verbose 7 Verbosity of output.",
45 "-datatype u Force writing of a new data type.",
46 "-subtractive Flag to calculate subtractive one-color conversions.",
47 "-grayextremes Flag to keep gray extremes beyond colorization limits.",
50 "-add file.tif Add this file to the input file (must be the same size).",
53 "-scale file.tif Output spectral scale image.",
54 "-phasewheel pcw.png Output a phase color wheel (size 512,512,1)."
59 int main(
int argc,
char **argv)
79 double cmin(0), cmax(0);
80 double red_min(0), white_min(0), white_max(0), blue_max(0);
88 for ( curropt = option; curropt; curropt = curropt->
next ) {
89 if ( curropt->
tag ==
"datatype" )
91 if ( curropt->
tag ==
"invert" )
93 if ( curropt->
tag ==
"red" ) {
94 if ( curropt->
values(cmin, cmax) < 2 )
95 cerr <<
"-red: A grayscale range must be specified!" << endl;
99 if ( curropt->
tag ==
"green" ) {
100 if ( curropt->
values(cmin, cmax) < 2 )
101 cerr <<
"-green: A grayscale range must be specified!" << endl;
105 if ( curropt->
tag ==
"blue" ) {
106 if ( curropt->
values(cmin, cmax) < 2 )
107 cerr <<
"-blue: A grayscale range must be specified!" << endl;
111 if ( curropt->
tag ==
"spectrum" ) {
112 if ( curropt->
values(cmin, cmax) < 2 )
113 cerr <<
"-spectrum: A grayscale range must be specified!" << endl;
117 if ( curropt->
tag ==
"rwb" ) {
118 if ( curropt->
values(red_min, white_min,
119 white_max, blue_max) < 4 )
120 cerr <<
"-rwb: 4 grayscale values must be specified!" << endl;
124 if ( curropt->
tag ==
"phases" )
126 if ( curropt->
tag ==
"intensities" )
128 if ( curropt->
tag ==
"pure" )
130 if ( curropt->
tag ==
"alpha" )
132 if ( curropt->
tag ==
"noalpha" )
134 if ( curropt->
tag ==
"torgb" )
136 if ( curropt->
tag ==
"tocmyk" )
138 if ( curropt->
tag ==
"split" )
140 if ( curropt->
tag ==
"combine" )
142 cerr <<
"-combine: The number of channels must be specified!" << endl;
143 if ( curropt->
tag ==
"subtractive" )
145 if ( curropt->
tag ==
"grayextremes" )
147 if ( curropt->
tag ==
"add" )
149 if ( curropt->
tag ==
"scale" )
151 if ( curropt->
tag ==
"phasewheel" )
165 if ( optind >= argc )
bexit(0);
169 if ( optind < argc - 1 ) dataflag = 1;
172 cerr <<
"Error: No input file read!" << endl;
179 if ( optind < argc ) {
180 if ( setinvert ) p->
invert();
192 if ( setred ) p->
color_red(cmin, cmax, flag);
196 if ( setblue ) p->
color_blue(cmin, cmax, flag);
201 pscale = p->
red_white_blue(red_min, white_min, white_max, blue_max);
203 if ( colour_phases ) {
218 if ( add_image.
length() ) {
234 if ( scale_image.
length() && pscale ) {
A class for a command line input option.
int color_green(double cmin, double cmax, int flag=0)
Converts a gray-scale image to green.
void rgb_to_cmyk()
Converts an RGB color image to CMYK.
void combine_channels(long nc)
The channels are composed from individual images.
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Header file for option handlers.
void split_channels()
The channels are split into individual images.
int phase_colour_wheel()
Generates a phase color wheel.
Bimage * color_spectrum(double cmin, double cmax)
Colorizes an image to a spectrum.
void rgba_to_rgb()
The alpha channel is delete from an RGBA color image.
Bimage * red_white_blue(double red_min, double white_min, double white_max, double blue_max)
Colorizes an image with blue positive and red negative.
long values(T1 &v1, T2 &v2)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
void cmyk_to_rgb()
Converts a CMYK color image to RGB.
General image parameter class.
Utilities for timing functions.
void color_to_simple()
A color image is converted to a simple image.
double timer_start()
Starts timer and prints the time.
int color_blue(double cmin, double cmax, int flag=0)
Converts a gray-scale image to blue.
Header file for general utilities.
vector< string > split(const string &s)
Splits a string on whitespace.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void rgb_to_rgba()
An alpha channel is added to a RGB color image.
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
void simple_to_rgb()
A simple image is converted to a color image.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
void invert()
Inverts the data in the image.
Bimage * intensities_phase_colored(double scale)
Generates a power spectrum with phases colored according to a color wheel.
int color_combine(Bimage *p)
Combines two colored images.
DataType
Base data type specifier.
int pure_color()
Generates a pure color image without intensity.
int main(int argc, char **argv)
int color_red(double cmin, double cmax, int flag=0)
Converts a gray-scale image to red.