 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
23 if ( compoundtype ==
TRGB )
return;
25 if ( compoundtype !=
TSimple ) {
26 cerr <<
"Error in simple_to_rgb: Conversion must be from simple to RGB!" << endl;
31 double scale = 255.0/(max - min);
37 for (
long j=0; j<ds; j++ ) {
38 v = ((*this)[j] +
shift) * scale;
60 if ( compoundtype ==
TRGBA )
return;
62 if ( compoundtype !=
TSimple ) {
63 cerr <<
"Error in simple_to_rgba: Conversion must be from simple to RGBA!" << endl;
68 double scale = 255.0/(max - min);
74 for (
long j=0; j<ds; j++ ) {
75 v = ((*this)[j] +
shift) * scale;
96 if ( compoundtype ==
TSimple )
return;
97 if ( compoundtype ==
TComplex )
return;
102 float* nudata =
new float[ds];
104 for (
long j=0; j<ds; j++ )
105 nudata[j] = (
rgb(j)).average();
124 if ( compoundtype ==
TRGBA )
return;
126 if ( compoundtype !=
TRGB ) {
127 cerr <<
"Error in Bimage::rgb_to_rgba: Conversion must be from RGB to RGBA!" << endl;
134 for (
long j=0; j<ds; j++ )
138 compoundtype =
TRGBA;
151 if ( compoundtype ==
TRGB )
return;
153 if ( compoundtype !=
TRGBA ) {
154 cerr <<
"Error in Bimage::rgba_to_rgb: Conversion must be from RGBA to RGB!" << endl;
161 for (
long j=0; j<ds; j++ )
178 if ( compoundtype ==
TCMYK )
return;
180 if ( compoundtype !=
TRGB ) {
181 cerr <<
"Error in Bimage::rgb_to_cmyk: Conversion must be from RGB to CMYK!" << endl;
189 for (
long j=0; j<ds; j++ ) {
195 compoundtype =
TCMYK;
208 if ( compoundtype ==
TRGB )
return;
210 if ( compoundtype !=
TCMYK ) {
211 cerr <<
"Error in Bimage::rgb_to_cmyk: Conversion must be from CMYK to RGB!" << endl;
219 for (
long j=0; j<ds; j++ ) {
249 if ( cmin == cmax ) {
255 cout <<
"Coloring the image: " << color << endl << endl;
258 double gscale = 255.0/(max - min);
259 double scale = 255.0/(cmax - cmin);
264 for ( i=0; i<datasize; i++ ) {
266 if ( ( v >= cmin ) && ( v <= cmax ) ) {
267 v = scale*(v - cmin);
269 if ( v > 255 ) v = 255;
271 for ( cc = 0; cc < 3; ++cc ) {
273 nudata[i][color] = 255;
275 nudata[i][cc] = (
unsigned char) (255 - v);
278 nudata[i][color] = (
unsigned char) v;
280 }
else if ( flag & 2 ) {
281 v = gscale*(v - min);
283 }
else if ( v > cmax ) {
284 nudata[i][color] = 255;
354 if ( compoundtype !=
TRGB && compoundtype !=
TRGBA )
return 0;
357 cout <<
"Generating a pure color image" << endl << endl;
362 for ( i=0; i<datasize; i+=c ) {
363 for (
sum=cc=0, j=i; cc<3; cc++, j++ )
sum += (*
this)[j];
366 for ( cc=0, j=i; cc<3; cc++, j++ )
367 set(j, (*
this)[j] * fac);
384 if ( compoundtype !=
TRGB && compoundtype !=
TRGBA )
return 0;
388 cout <<
"Combining two color images" << endl << endl;
393 for ( i=0; i<datasize; i+=c ) {
394 for ( cc=0, j=i; cc<c; cc++, j++ ) {
395 v = (*this)[j] + (*p)[j];
396 if ( v > 255 ) v = 255;
419 if ( cmin == cmax ) {
425 cout <<
"Coloring the image" << endl << endl;
429 double gscale(255.0/(max - min));
433 for ( i=0; i<datasize; i++ ) {
434 value = (*this)[i*c];
435 if ( ( value >= cmin ) && ( value <= cmax ) ) {
436 nudata[i].
spectrum(value, cmin, cmax);
438 value = gscale*(value - min);
451 cout <<
"Generating a color scale image" << endl << endl;
458 for ( i=0; i<p->
sizeX(); i++ ) {
459 rgb.spectrum((
double)i, 0.0, 255.0);
479 double white_max,
double blue_max)
482 cout <<
"Generating a red-white-blue image:" << endl;
483 cout <<
"Red gradient start and end: " << red_min <<
" " << white_min << endl;
484 cout <<
"Blue gradient start and end: " << white_max <<
" " << blue_max << endl;
486 cout <<
"Generating a red-white-blue image" << endl << endl;
491 double blue_scale(255.0/(blue_max - white_max));
492 double red_scale(255.0/(white_min - red_min));
497 for ( i=0; i<datasize; i++ ) {
499 red = grn = blu = 255;
500 if ( v > blue_max ) {
502 }
else if ( v < red_min ) {
504 }
else if ( v > white_max ) {
505 red = (int) (blue_scale*(blue_max - v));
506 grn = (int) (blue_scale*(blue_max - v));
507 }
else if ( v < white_min ) {
508 blu = (int) (red_scale*(v - red_min));
509 grn = (int) (red_scale*(v - red_min));
511 if ( red < 0 ) red = 0;
512 if ( red > 255 ) red = 255;
513 if ( grn < 0 ) grn = 0;
514 if ( grn > 255 ) grn = 255;
515 if ( blu < 0 ) blu = 0;
516 if ( blu > 255 ) blu = 255;
528 cout <<
"Generating a color scale image: colorscale.tif" << endl << endl;
531 double scale((max - min)/255);
535 for ( i=0; i<p->
sizeX(); i++ ) {
536 red = grn = blu = 255;
538 if ( v > blue_max ) {
540 }
else if ( v < red_min ) {
542 }
else if ( v > white_max ) {
543 red = (int) (blue_scale*(blue_max - v));
544 grn = (int) (blue_scale*(blue_max - v));
545 }
else if ( v < white_min ) {
546 blu = (int) (red_scale*(v - red_min));
547 grn = (int) (red_scale*(v - red_min));
549 if ( red < 0 ) red = 0;
550 if ( red > 255 ) red = 255;
551 if ( grn < 0 ) grn = 0;
552 if ( grn > 255 ) grn = 255;
553 if ( blu < 0 ) blu = 0;
554 if ( blu > 255 ) blu = 255;
577 double rx, ry, a, r, rmax(256);
582 for ( i=yy=0; yy<y; yy++ ) {
584 for ( xx=0; xx<x; xx++, i++ ) {
587 r = sqrt(rx*rx + ry*ry);
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.
int shift(Vector3< double > vec, int fill_type=0, double fill=0)
Shifts an image.
void set(long j, double v)
Sets a single value at the given index.
Bimage()
Initializes an image.
void sum(long m, Bimage **p)
Sums an array of images with their FOM blocks.
Vector3< long > size() const
int phase_colour_wheel()
Generates a phase color wheel.
RGBA< double > rgba(long j)
Returns a color value at the given index.
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.
void origin(double x, double y, double z)
void spectrum(double value, double cmin, double cmax)
void cmyk_to_rgb()
Converts a CMYK color image to RGB.
General image parameter class.
CompoundType compound_type()
void color_to_simple()
A color image is converted to a simple image.
Header file for image class.
int color_blue(double cmin, double cmax, int flag=0)
Converts a gray-scale image to blue.
Header file for general utilities.
void origin(double ox, double oy, double oz)
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.
int one_color(int color, double cmin, double cmax, int flag=0)
Converts a gray-scale image to a single color.
void simple_to_rgb()
A simple image is converted to a color image.
CMYK< double > cmyk(long j)
Returns a color value at the given index.
unsigned char * data_assign(unsigned char *nudata)
Assign image data.
int color_combine(Bimage *p)
Combines two colored images.
int pure_color()
Generates a pure color image without intensity.
void simple_to_rgba()
A simple image is converted to a color image.
RGB< double > rgb(long j)
Returns a color value at the given index.
long statistics()
Calculates the statistics for an image.
int color_red(double cmin, double cmax, int flag=0)
Converts a gray-scale image to red.