This archive contains a command line tool (colortransf v. 1.1) for performing reversible and irreversible color space transformations, including established standard transformations as well as new ones. Reversible color space transformations are described in: R. Starosolski, New simple and efficient color space transformations for lossless image compression, Journal of Visual Communication and Image Representation, 2014, Vol. 25(5), pp. 1056-63, http://dx.doi.org/10.1016/j.jvcir.2014.03.003. Irreversible transformations are described in: R. Starosolski, Human Visual System Inspired Color Space Transform in Lossy JPEG 2000 and JPEG XR Compression, submitted. This archive contains files: readme.txt - this file colortransf.cpp - a C++ source file of the colortransf tool colortransf.exe - Win32 executable Further description (the same will be outputted by the tool invoked with no arguments): colortransf v. 1.1, (c) 2014, 2016 Roman Starosolski, rstarosolski@polsl.pl Apply color space transformation to RGB image obtaining transformed components, or recreate the RGB image from components using inverse transformation. Reversible color space transformations are described in: R. Starosolski, New simple and efficient color space transformations for lossless image compression, Journal of Visual Communication and Image Representation, 2014, Vol. 25(5), pp. 1056-63, http://dx.doi.org/10.1016/j.jvcir.2014.03.003. Irreversible transformations are described in: R. Starosolski, Human Visual System Inspired Color Space Transform in Lossy JPEG 2000 and JPEG XR Compression, submitted. Image formats: PPM P6 (for RGB image), PGM P5 (for components), PPM plane order RGB assumed, untransformed and transformed intensities assumed unsigned. This software is intended for research purposes only; it is provided "as is"; author makes no warranty of any kind, either express or implied, with respect to this software. This work was partially supported by the POIG.02.03.01-24-099/13 grant: GeCONiI - Upper-Silesian Center for Scientific Computations. syntax: colortransf [switches] command commands: S infilergb.ppm redT.pgm greenT.pgm blueT.pgm // split image into components, apply (optional) transformation U redT.pgm greenT.pgm blueT.pgm outfilergb.ppm // unsplit TEST_TRANSF range // test forward & inverse rebersible transformation for all // possible combinations of component values in given range // checking dynamic ranges of components and reversibility TEST_IRREV range // test forward & inverse irreversible transformation for all // possible combinations of component values in given range // checking component depth violations and forward/inverse // transformation errors switches: [-TRANSF nr] // apply transformation number nr (numbers listed below), for a detailed // description of transformations and components' formulas see the above // mentioned paper // // reversible transformations with inverses (* - 1-bit expansion): // 0 - RGB (no transformation, default), // components outputted in a following order: R G B // 1 - RCT (from JPEG2000 standard), // components outputted in a following order: Cv* Y Cu* // -1 - inverse RCT // 2 - YCoCg-R (from JPEG-XR standard), // components outputted in a following order: Co* Y Cg* // -2 - inverse YCoCg-R // 3 - RDgDb, // components outputted in a following order: R Dg* Db* // -3 - inverse RDgDb // 4 - A2, // components outputted in a following order: VA2* YA2 UA2* // -4 - inverse A2 // 5 - LDgEb, // components outputted in a following order: L Dg* Eb* // -5 - inverse LDgEb // 6 - LDgDb, // components outputted in a following order: L Dg* Db* // -6 - inverse LDgDb // 7 - mRCT (from extended JPEG-LS standard), // components outputted in a following order: mCv mY mCu // -7 - inverse mRCT // 8 - mRDgDb, // components outputted in a following order: R mDg mDb // -8 - inverse mRDgDb // 9 - mA2, // components outputted in a following order: mVA2 mYA2 mUA2 // -9 - inverse mA2 // 10 - mLDgEb, // components outputted in a following order: mL mDg mEb // -10 - inverse mLDgEb // 11 - mLDgDb, // components outputted in a following order: mL mDg mDb // -11 - inverse mLDgDb // // for testing components' formulas (no inverse, * - 1-bit expansion): // 20 - ADDAVG, components outputted in a following order: // ((2r+g+b)/4) ((2g+b+r)/4) ((2b+r+g)/4) // 21 - SUB, components outputted in a following order: // (r-g)* (g-b)* (b-r)* // 22 - INVSUB, components outputted in a following order: // (g-r)* (b-g)* (r-b)* // 23 - ADDHALF, components outputted in a following order: // (r+g)/2 (g+b)/2 (b+r)/2 // 24 - SUBAVG, components outputted in a following order: // ((2r-g-b)/2)* ((2g-b-r)/2)* ((2b-r-g)/2*) // // irreversible transformations with inverses // 30 - ICT (from JPEG2000 standard) // components outputted in a following order: Y Cr Cb // -30 - inverse ICT // 31 - YCoCg (irreversible variant of YCoCg-R from JPEG-XR standard) // components outputted in a following order: Y Co Cg // -31 - inverse YCoCg // 32 - HVSCT (irreversible variant of LDgEb) // components outputted in a following order: Y Cd Ce // -32 - inverse HVSCT // [-O_RAW] // output as RAW (skip PGM/PPM header) [-NO_INV_CHECK] // skip checking inverse transformation (or reversibility), default is to // check for each pixel before outputting it (S and U commands); for the // TEST_TRANSF command check ranges only (skip reversibility check) [-U_FORCE_CLIP] // clip inverse transformed components (for all transformations, done in // U command), use after lossy compression of transformed components; // default: do not clip [-NO_IRREV_CLIP] // for irreversible transforms only: skip clipping of transformed // components; default: clip examples: Split lena.ppm RGB color image into red green and blue components, saved as grayscale images R.ppm G.ppm B.ppm: colortransf S lena.ppm R.pgm G.pgm B.pgm Transform lena.ppm using YCoCg-R transformation, save resulting components as Co.ppm Y.ppm Cg.ppm: colortransf -TRANSF 2 S lena.ppm Co.pgm Y.pgm Cg.pgm Apply inverse YCoCg-R transformation on Co.pgm Y.pgm Cg.pgm components, save resulting image as lena2.ppm: colortransf -TRANSF -2 U Co.ppm Y.pgm Cg.pgm lena2.ppm Convert lena.ppm RGB color image to BRG space and apply mRCT transformation on image with permuted components: colortransf S lena.ppm R.pgm G.pgm B.pgm colortransf U B.pgm R.pgm G.pgm lenaBRG.ppm colortransf -TRANSF 7 S lenaBRG.ppm mCvBRG.pgm mYBRG.pgm mCuBRG.pgm Transform lena.ppm using irreversible ICT transformation, save resulting components as iY.ppm iCr.ppm iCb.ppm: colortransf -TRANSF 30 -NO_INV_CHECK S lena.ppm iY.pgm iCr.pgm iCb.pgm Generate components being primary color differences (irreversible operation): colortransf -TRANSF 21 -NO_INV_CHECK S lena.ppm R-G.pgm G-B.pgm B-R.pgm What errors are introduced due to forward and inverse irreversible ICT transformation, for component values in 0..255 range? colortransf -TRANSF 30 TEST_IRREV 256 Is mLDgEb really reversible for all possible combinations of component values in 0..255 range? colortransf -TRANSF 10 TEST_TRANSF 256