#include <HxImageFactory.h>
Public Methods | |
HxImageRep | fromSignature (const HxImageSignature &signature, HxSizes sizes) |
Uninitialized image with given signature and sizes. More... | |
HxImageRep | fromImage (const HxImageSignature &signature, HxImageRep src) |
New image with given signature. More... | |
HxImageRep | fromValue (const HxImageSignature &signature, HxSizes sizes, HxValue val) |
New image with given signature and sizes. More... | |
HxImageRep | fromByteData (int pixelDimensionality, int dimensions, HxSizes sizes, HxByte *data) |
New image with given signature and sizes. More... | |
HxImageRep | fromShortData (int pixelDimensionality, int dimensions, HxSizes sizes, short *data) |
New image with given signature and sizes. More... | |
HxImageRep | fromIntData (int pixelDimensionality, int dimensions, HxSizes sizes, int *data) |
New image with given signature and sizes. More... | |
HxImageRep | fromFloatData (int pixelDimensionality, int dimensions, HxSizes sizes, float *data) |
New image with given signature and sizes. More... | |
HxImageRep | fromDoubleData (int pixelDimensionality, int dimensions, HxSizes sizes, double *data) |
New image with given signature and sizes. More... | |
HxImageRep | fromGenerator (const HxImageSignature &signature, const HxImageGenerator *imgGenerator) const |
New image with given signature. More... | |
HxImageRep | fromNamedGenerator (const HxImageSignature &signature, HxString generatorName, HxTagList &tags) const |
New image with given signature. More... | |
HxImageRep | fromJavaRgb (const HxImageSignature &signature, HxSizes sizes, int *pixels) |
New image with given signature and sizes. More... | |
HxImageRep | fromGrayValue (const HxImageSignature &signature, HxSizes sizes, HxByte *pixels) |
New image with given signature and sizes. More... | |
HxImageRep | fromMatlab (const HxImageSignature &signature, HxSizes sizes, double *pixels) |
New image with given signature and sizes. More... | |
HxImageRep | fromImport (const HxImageSignature &signature, HxSizes sizes, HxString importOp, HxTagList &tags) |
New image with given signature and sizes. More... | |
HxImageRep | from2Images (HxImageRep i1, HxImageRep i2) |
New image with pixel values "stacked" from given arguments. More... | |
HxImageRep | from3Images (HxImageRep i1, HxImageRep i2, HxImageRep i3) |
New image with pixel values "stacked" from given arguments. More... | |
HxImageRep | fromFile (HxString fileName, HxTagList &tags) |
New image read from file using HxImgFileIo lib. More... | |
bool | writeFile (HxImageRep img, HxString fileName, HxTagList &tags) const |
Write image to file using HxImgFileIo lib. More... | |
bool | imagesToFile (HxImageList imgs, HxString fileName, HxTagList &tags) const |
Write set of image to file using HxImgFileIo lib. More... | |
HxImageList | imagesFromFile (HxString fileName, HxTagList &tags) |
Read set of image from file using HxImgFileIo lib. More... | |
void | subscribeGenerator (HxString name, HxImageGenerator *) |
void | unSubscribeGenerator (HxString name, HxImageGenerator *) |
HxImageGenerator * | getGenerator (HxString name) const |
Static Public Methods | |
HxImageFactory & | instance () |
The one and only instance of this class. More... |
|
The one and only instance of this class.
00024 { 00025 static HxImageFactory theFactory; 00026 return theFactory; 00027 } |
|
Uninitialized image with given signature and sizes.
00032 { 00033 HxImageData* imgData = construct(signature, sizes); 00034 return HxImageRep(imgData); 00035 } |
|
New image with given signature. Sizes and data are taken from given image.
00039 { 00040 HxImageData* imgData = construct(signature, src.sizes()); 00041 if (imgData && src.pointee()) 00042 imgData->set(src.pointee()); 00043 return HxImageRep(imgData); 00044 } |
|
New image with given signature and sizes. Pixel data is initialized with given value.
00049 { 00050 HxImageData* imgData = construct(signature, sizes); 00051 if (imgData) 00052 imgData->set(val); 00053 return HxImageRep(imgData); 00054 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00059 { 00060 HxImageSignature signature( 00061 dimensions, pixelDimensionality, INT_VALUE, sizeof(HxByte)<<3); 00062 HxImageData* imgData = construct(signature, sizes); 00063 if (imgData) 00064 imgData->import(data); 00065 return HxImageRep(imgData); 00066 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00071 { 00072 HxImageSignature signature( 00073 dimensions, pixelDimensionality, INT_VALUE, sizeof(short)<<3); 00074 HxImageData* imgData = construct(signature, sizes); 00075 if (imgData) 00076 imgData->import(data); 00077 return HxImageRep(imgData); 00078 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00083 { 00084 HxImageSignature signature( 00085 dimensions, pixelDimensionality, INT_VALUE, sizeof(int)<<3); 00086 HxImageData* imgData = construct(signature, sizes); 00087 if (imgData) 00088 imgData->import(data); 00089 return HxImageRep(imgData); 00090 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00095 { 00096 HxImageSignature signature( 00097 dimensions, pixelDimensionality, REAL_VALUE, sizeof(float)<<3); 00098 HxImageData* imgData = construct(signature, sizes); 00099 if (imgData) 00100 imgData->import(data); 00101 return HxImageRep(imgData); 00102 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00107 { 00108 HxImageSignature signature( 00109 dimensions, pixelDimensionality, REAL_VALUE, sizeof(double)<<3); 00110 HxImageData* imgData = construct(signature, sizes); 00111 if (imgData) 00112 imgData->import(data); 00113 return HxImageRep(imgData); 00114 } |
|
New image with given signature. Pixel data and size are determined by image generator.
00120 { 00121 HxImageData* imgData = construct(signature, imgGenerator->domainSize()); 00122 HxTagList tags; 00123 HxAddTag(tags, "imageGenerator", imgGenerator); 00124 if (imgData) 00125 { 00126 imgData->inout("generate", tags); 00127 } 00128 return HxImageRep(imgData); 00129 } |
|
New image with given signature. Pixel data and size are determined by image generator.
00135 { 00136 HxImageGenerator* generator = getGenerator(generatorName); 00137 00138 if (!generator) 00139 return HxImageRep(); 00140 00141 generator->init(tags); 00142 HxImageData* imgData = construct(signature, generator->domainSize()); 00143 HxTagList ttags; 00144 HxAddTag(ttags, "imageGenerator", generator); 00145 if (imgData) 00146 { 00147 imgData->inout("generate", ttags); 00148 } 00149 return HxImageRep(imgData); 00150 } |
|
New image with given signature and sizes. Pixel data is initialized from given values. The given values are stored in Java RGB format.
00155 { 00156 HxImageData* imgData = construct(signature, sizes); 00157 if (imgData) 00158 imgData->set(pixels); 00159 return HxImageRep(imgData); 00160 } |
|
New image with given signature and sizes. Pixel data is initialized from given values.
00165 { 00166 HxImageData* imgData = construct(signature, sizes); 00167 if (imgData) 00168 imgData->set(pixels); 00169 return HxImageRep(imgData); 00170 } |
|
New image with given signature and sizes. Pixel values are initialized from given values. The given values are stored in Matlab format.
00175 { 00176 HxImageData* imgData = construct(signature, sizes); 00177 if (imgData) 00178 imgData->set(pixels); 00179 return HxImageRep(imgData); 00180 } |
|
New image with given signature and sizes. Pixel values are initialized by specified import operator.
00186 { 00187 HxImageData* imgData = construct(signature, sizes); 00188 if (imgData) 00189 imgData->inout(importOp, tags); 00190 return HxImageRep(imgData); 00191 } |
|
New image with pixel values "stacked" from given arguments. For example, if i1 and i2 are scalar images the pixel values in the new image are 2-vectors. Result may need exceed highest pixel dimensionality.
00195 { 00196 STD_OSTREAM& errorStream = HxEnvironment::instance()->errorStream(); 00197 00198 if (!(i1 && i2)) { 00199 errorStream << "Source images may not be null" << STD_ENDL; 00200 HxEnvironment::instance()->flush(); 00201 return HxImageRep(); 00202 } 00203 if (i1.signature() != i2.signature()) { 00204 errorStream << "Source images differ in type" << STD_ENDL; 00205 HxEnvironment::instance()->flush(); 00206 return HxImageRep(); 00207 } 00208 if (i1.sizes() != i2.sizes()) { 00209 errorStream << "Source images differ in size" << STD_ENDL; 00210 HxEnvironment::instance()->flush(); 00211 return HxImageRep(); 00212 } 00213 HxImageSignature signature(i1.signature()); 00214 HxSizes sizes(i1.sizes()); 00215 00216 if (signature.pixelDimensionality() != 1) { 00217 errorStream << "HxImageRep: images must have pixelDimensionality of 1" 00218 << STD_ENDL; 00219 HxEnvironment::instance()->flush(); 00220 return HxImageRep(); 00221 } 00222 signature.setPixelDimensionality(2); 00223 HxImageData* imgData = construct(signature, sizes); 00224 if (imgData) 00225 { 00226 HxTagList tags; 00227 imgData->binaryPixOp( 00228 i1.pointee(), i2.pointee(), "vector2d", tags); 00229 } 00230 return HxImageRep(imgData); 00231 } |
|
New image with pixel values "stacked" from given arguments. For example, if i1, i2, and i3 are scalar images the pixel values in the new image are 3-vectors. Result may need exceed highest pixel dimensionality.
00235 { 00236 STD_OSTREAM& errorStream = HxEnvironment::instance()->errorStream(); 00237 if (!(i1 && i2 && i3)) { 00238 errorStream << "Source images may not be null" << STD_ENDL; 00239 HxEnvironment::instance()->flush(); 00240 return HxImageRep(); 00241 } 00242 if ((i1.signature() != i2.signature()) 00243 || (i2.signature() != i3.signature())) { 00244 errorStream << "Source images differ in type" << STD_ENDL; 00245 HxEnvironment::instance()->flush(); 00246 return HxImageRep(); 00247 } 00248 if ((i1.sizes() != i2.sizes()) || (i2.sizes() != i3.sizes())) { 00249 errorStream << "Source images differ in size" << STD_ENDL; 00250 HxEnvironment::instance()->flush(); 00251 return HxImageRep(); 00252 } 00253 HxImageSignature signature(i1.signature()); 00254 HxSizes sizes(i1.sizes()); 00255 if (signature.pixelDimensionality() != 1) { 00256 errorStream << "HxImageRep: images must have pixelDimensionality of 1" 00257 << STD_ENDL; 00258 HxEnvironment::instance()->flush(); 00259 return HxImageRep(); 00260 } 00261 signature.setPixelDimensionality(3); 00262 HxImageData* imgData = construct(signature, sizes); 00263 if (imgData) 00264 { 00265 HxTagList tags; 00266 HxImageData *pointees[3] = {i1.pointee(), i2.pointee(), i3.pointee()}; 00267 imgData->multiPixOp(pointees, 3, "vector3d", tags); 00268 } 00269 return HxImageRep(imgData); 00270 } |
|
New image read from file using HxImgFileIo lib.
00276 { 00277 HxString extName = HxSystem::instance().extName(fileName); 00278 00279 HxImgFileReader* reader = HxImgFileIoTable::instance().getReader(extName); 00280 00281 int imgNum = HxGetTag(tags, "setImage", 0); 00282 00283 if (!reader) 00284 { 00285 HxEnvironment::instance()->errorStream() 00286 << "Unknown file type \"" << extName << "\"" << STD_ENDL; 00287 HxEnvironment::instance()->flush(); 00288 return HxImageRep(); 00289 } 00290 00291 if (reader->openFile(fileName)) 00292 { 00293 HxImageData* imgData = 0; 00294 00295 bool imgIsSet = reader->setImage(imgNum); 00296 reader->getInfo(tags); 00297 if (imgIsSet) 00298 { 00299 HxPointZ begin(0, 0, 0); 00300 HxTagList tags; 00301 imgData = construct( 00302 reader->getSignature(), reader->getImageSize()); 00303 HxString inOutOp = 00304 HxString("importPix<") + reader->getDataTypeString() + ">"; 00305 while (reader->moreData()) 00306 { 00307 HxBoundingBox boundingBox(reader->getDataSize()); 00308 boundingBox = boundingBox.translate(reader->getDataBegin()); 00309 HxAddTag(tags, "boundingBox", boundingBox); 00310 void* data = reader->getData(); 00311 if (data) 00312 imgData->inout( 00313 data, reader->getDataTypeString(), "importPix", tags); 00314 } 00315 } 00316 else 00317 { 00318 HxEnvironment::instance()->errorStream() 00319 << "" << reader->errorDescription() << STD_ENDL; 00320 HxEnvironment::instance()->flush(); 00321 } 00322 reader->closeFile(); 00323 return imgData ? HxImageRep(imgData) : HxImageRep(); 00324 } 00325 else 00326 { 00327 HxEnvironment::instance()->errorStream() 00328 << "" << reader->errorDescription() << STD_ENDL; 00329 HxEnvironment::instance()->flush(); 00330 } 00331 00332 return HxImageRep(); 00333 } |
|
Write image to file using HxImgFileIo lib.
00338 { 00339 if (!img) return false; 00340 00341 HxString extName = HxSystem::instance().extName(fileName); 00342 00343 HxImgFileWriter* writer = HxImgFileIoTable::instance().getWriter(extName); 00344 00345 if (!writer) 00346 { 00347 HxEnvironment::instance()->errorStream() 00348 << "Unknown file type \"" << extName << "\"" << STD_ENDL; 00349 HxEnvironment::instance()->flush(); 00350 return false; 00351 } 00352 00353 bool asRgb = HxGetTag(tags, "asRgb", true); 00354 HxAddTag(tags, "asRgb", asRgb); 00355 00356 if (!(writer->openFile(fileName) && 00357 writer->setSignature(img.signature()) && 00358 writer->setImageSize(img.sizes()) && 00359 writer->setInfo(tags))) 00360 { 00361 HxEnvironment::instance()->errorStream() 00362 << "" << writer->errorDescription() << STD_ENDL; 00363 HxEnvironment::instance()->flush(); 00364 return false; 00365 } 00366 00367 HxPointZ begin(0, 0, 0); 00368 HxTagList opTags; 00369 00370 while (writer->moreData()) 00371 { 00372 HxString exportName = "exportPix<" + writer->getDataTypeString() + ">"; 00373 HxBoundingBox boundingBox(writer->getDataSize()); 00374 boundingBox = boundingBox.translate(writer->getDataBegin()); 00375 HxAddTag(opTags, "boundingBox", boundingBox); 00376 void* data = writer->getData(); 00377 if (data) 00378 { 00379 HxAddTag(opTags, "dataPtr", data); 00380 img.exportOp(exportName, opTags); 00381 writer->putData(data); 00382 } 00383 } 00384 00385 writer->closeFile(); 00386 00387 return true; 00388 } |
|
Write set of image to file using HxImgFileIo lib.
00457 { 00458 if (!imgs.size()) return false; 00459 00460 HxString extName = HxSystem::instance().extName(fileName); 00461 00462 HxImgFileWriter* writer = HxImgFileIoTable::instance().getWriter(extName); 00463 00464 if (!writer) 00465 { 00466 HxEnvironment::instance()->errorStream() 00467 << "Unknown file type \"" << extName << "\"" << STD_ENDL; 00468 HxEnvironment::instance()->flush(); 00469 return false; 00470 } 00471 00472 bool asRgb = HxGetTag(tags, "asRgb", true); 00473 HxAddTag(tags, "asRgb", asRgb); 00474 00475 HxImageList::const_iterator img = imgs.begin(); 00476 00477 if (!(writer->firstImage() && 00478 writer->openFile(fileName) && 00479 writer->setSignature((*img).signature()) && 00480 writer->setImageSize((*img).sizes()) && 00481 writer->setInfo(tags))) 00482 { 00483 HxEnvironment::instance()->errorStream() 00484 << "" << writer->errorDescription() << STD_ENDL; 00485 HxEnvironment::instance()->flush(); 00486 return false; 00487 } 00488 00489 HxTagList opTags; 00490 00491 while (img != imgs.end()) { 00492 while (writer->moreData()) 00493 { 00494 HxString exportName = "exportPix<" + writer->getDataTypeString() + ">"; 00495 HxBoundingBox boundingBox(writer->getDataSize()); 00496 boundingBox = boundingBox.translate(writer->getDataBegin()); 00497 HxAddTag(opTags, "boundingBox", boundingBox); 00498 void* data = writer->getData(); 00499 if (data) 00500 { 00501 HxAddTag(opTags, "dataPtr", data); 00502 (*img).exportOp(exportName, opTags); 00503 writer->putData(data); 00504 } 00505 } 00506 img++; 00507 if (img != imgs.end()) { 00508 writer->nextImage(); 00509 if (!( writer->setSignature((*img).signature()) && 00510 writer->setImageSize((*img).sizes()) && 00511 writer->setInfo(tags))) 00512 { 00513 HxEnvironment::instance()->errorStream() 00514 << "" << writer->errorDescription() << STD_ENDL; 00515 HxEnvironment::instance()->flush(); 00516 return false; 00517 } 00518 } 00519 } 00520 00521 writer->closeFile(); 00522 00523 return true; 00524 } |
|
Read set of image from file using HxImgFileIo lib.
00392 { 00393 HxString extName = HxSystem::instance().extName(fileName); 00394 00395 HxImgFileReader* reader = HxImgFileIoTable::instance().getReader(extName); 00396 00397 HxImageList imgs; 00398 00399 if (!reader) 00400 { 00401 HxEnvironment::instance()->errorStream() 00402 << "Unknown file type \"" << extName << "\"" << STD_ENDL; 00403 HxEnvironment::instance()->flush(); 00404 return imgs; 00405 } 00406 00407 if (reader->openFile(fileName)) 00408 { 00409 int imgNum; 00410 for (imgNum = 0; imgNum < reader->imageCount(); imgNum++) { 00411 bool imgIsSet = reader->setImage(imgNum); 00412 reader->getInfo(tags); 00413 00414 if (imgIsSet) 00415 { 00416 HxImageData* imgData = 0; 00417 HxPointZ begin(0, 0, 0); 00418 HxTagList tags; 00419 imgData = construct( 00420 reader->getSignature(), reader->getImageSize()); 00421 HxString inOutOp = 00422 HxString("importPix<") + reader->getDataTypeString() + ">"; 00423 while (reader->moreData()) 00424 { 00425 HxBoundingBox boundingBox(reader->getDataSize()); 00426 boundingBox = boundingBox.translate(reader->getDataBegin()); 00427 HxAddTag(tags, "boundingBox", boundingBox); 00428 void* data = reader->getData(); 00429 if (data && imgData) 00430 imgData->inout( 00431 data, reader->getDataTypeString(), "importPix", tags); 00432 } 00433 imgs += imgData ? HxImageRep(imgData) : HxImageRep(); 00434 } 00435 else 00436 { 00437 HxEnvironment::instance()->errorStream() 00438 << "" << reader->errorDescription() << STD_ENDL; 00439 HxEnvironment::instance()->flush(); 00440 } 00441 } 00442 reader->closeFile(); 00443 } 00444 else 00445 { 00446 HxEnvironment::instance()->errorStream() 00447 << "" << reader->errorDescription() << STD_ENDL; 00448 HxEnvironment::instance()->flush(); 00449 } 00450 00451 return imgs; 00452 } |