39 #include <Base/Image/ImageBase.hh>
40 #include <Base/Image/ImageConvert.hh>
41 #include <Base/Image/ImageIO.hh>
48 unsigned int size=800;
51 unsigned int block_field_size=size/4;
52 unsigned int c=0, r=0;
53 unsigned char **ida=im.GetImageDataArray();
54 cerr<<
"R=255, G=0, B=0-255 | ";
56 for (c=0;c<block_field_size;c++) {
57 for (r=0; r< (block_field_size / 2) ; r++) {
60 ida[r][c*3 + 2]= (
unsigned char)blue;
62 blue+=255.0f / (float)block_field_size;
65 cerr<<
"R=255, G=0-255, B=255 | ";
67 for (c=block_field_size+1;c<(2*block_field_size);c++) {
68 for (r=0; r< (block_field_size / 2) ; r++) {
70 ida[r][c*3 + 1]= (
unsigned char)green;
73 green+=255.0f / (float)block_field_size;
76 cerr<<
"R=255, G=255, B=255-0 | ";
78 for (c=2*block_field_size+1;c<(3*block_field_size);c++) {
79 for (r=0; r< (block_field_size / 2) ; r++) {
82 ida[r][c*3 + 2]= (
unsigned char)blue;
84 blue-=255.0f / (float)block_field_size;
87 cerr<<
"R=255, G=255, B=255-0"<<endl;
89 for (c=3*block_field_size+1; c<size;c++) {
90 for (r=0; r< (block_field_size / 2) ; r++) {
92 ida[r][c*3 + 1]= (
unsigned char)green;
95 green-=255.0f / (float)block_field_size;
97 cerr<<
"--------------------------------------------------------------"<<endl;
98 cerr<<
"R=0, G=0-255, B=255 | ";
100 for (c=0;c<block_field_size;c++) {
101 for (r=block_field_size / 2 +1; r< block_field_size ; r++) {
103 ida[r][c*3 + 1]= (
unsigned char)green;
104 ida[r][c*3 + 2]= 255;
106 green+=255.0f / (float)block_field_size;
109 cerr<<
"R=0, G=255, B=255-0 | ";
111 for (c=block_field_size+1;c<(2*block_field_size);c++) {
112 for (r=block_field_size / 2 +1; r< block_field_size ; r++) {
114 ida[r][c*3 + 1]= 255;
115 ida[r][c*3 + 2]= (
unsigned char)blue;
117 blue-=255.0f / (float)block_field_size;
120 cerr<<
"R=0-255, G=255-0, B=0 | ";
123 for (c=2*block_field_size+1;c<(3*block_field_size);c++) {
124 for (r=block_field_size / 2 +1; r< block_field_size ; r++) {
125 ida[r][c*3 + 0]= (
unsigned char)red;
126 ida[r][c*3 + 1]= (
unsigned char)green;
129 green-=255.0f / (float)block_field_size;
130 red+=255.0f / (float)block_field_size;
133 cerr<<
"R=255-0, G=0, B=0-255"<<endl;
135 for (c=3*block_field_size+1; c<size;c++) {
136 for (r=block_field_size / 2 +1; r< block_field_size ; r++) {
137 ida[r][c*3 + 0]= (
unsigned char)red;
141 red-=255.0f / (float)block_field_size;
142 blue+=255.0f / (float)block_field_size;
148 cerr<<
"-------------------------------------------------------"<<endl;
149 cerr<<
"corresonding HSV channels: ";
150 cerr<<
"hue , saturation and value"<<endl;
152 unsigned char **idaHSV=imageHSV.GetImageDataArray();
153 for (c=0;c<size;c++) {
154 for (r=0;r< block_field_size;r++) {
156 ida[r/2+block_field_size+20][c*3 + 0] = idaHSV[r][c*3 + 0];
157 ida[r/2+block_field_size+20][c*3 + 1] = idaHSV[r][c*3 + 0];
158 ida[r/2+block_field_size+20][c*3 + 2] = idaHSV[r][c*3 + 0];
160 ida[r/2+2*block_field_size+20][c*3 + 0] = idaHSV[r][c*3 + 1];
161 ida[r/2+2*block_field_size+20][c*3 + 1] = idaHSV[r][c*3 + 1];
162 ida[r/2+2*block_field_size+20][c*3 + 2] = idaHSV[r][c*3 + 1];
164 ida[r/2+3*block_field_size+20][c*3 + 0] = idaHSV[r][c*3 + 2];
165 ida[r/2+3*block_field_size+20][c*3 + 1] = idaHSV[r][c*3 + 2];
166 ida[r/2+3*block_field_size+20][c*3 + 2] = idaHSV[r][c*3 + 2];
173 BIASERR(
"error writing image ");
178 BIASERR(
"error exporting image ");
181 cerr<<
"image data written to file: imageHSVExample. ppm/mip"<<endl;
color values, 3 channels, order: red,green,blue
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
static int Convert(BIAS::ImageBase &source, BIAS::ImageBase &dest, enum BIAS::ImageBase::EColorModel targetColorModel, bool bPlanar=false)
main general conversion function, calls desired specialized functions, always initializes the destIma...
HSV, 3 channels, order: hue, sat , value.