This archive contains the implementation of the hybrid transform RDLS-SS-DWT+Pred in JPEG 2000 codec (RDLS-SS-DWT v. 1.0), which was used in a research described in [5]. 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. The RDLS-SS-DWT v. 1.0 is based on the IRIS-JP3D JPEG 2000 part 10 (JP3D) reference software developed by Tim Bruylants from Vrije Universiteit Brussel (VUB) and the Interdisciplinary Institute for BroadBand Technology (IBBT), version 1.1.1 (http://www.etrovub.be/INDUSTRY/KnowHow/, see [3]). Since using IRIS-JP3D v. 1.1.1 requires acquiring a licence from its Authors (free for research purposes), the RDLS-SS-DWT v. 1.0 is distributed as a patch to the IRIS-JP3D v. 1.1.1. (c) 2015, 2020 Roman Starosolski The archive rdls_ss_dwt_10.zip contains: -jp3d_1_1_1.rdls_ss_dwt_10.patch - a patch (unified output format) to IRIS-JP3D v. 1.1.1 source .c and .h files, -RS_vol_ops.c, RS_vol_ops.h - additional files needed to build RDLS-SS-DWT v. 1.0; -strtok_s.c, strtok_s.h - additional files needed to build RDLS-SS-DWT v. 1.0 using MinGW-W64; strtok_s uses public domain strtok_r() function code by Charlie Gordon, from comp.lang.c 9/14/2007 -readme.txt - this file, -RS__transfpar.dat.* - sample text configuration files for RDLS-SS-DWT v. 1.0 (see comments inside). -gcc64it.bat - batch file for GCC compilation of RDLS-SS-DWT v. 1.0, -test.bat - batch for testing compiled RDLS-SS-DWT v. 1.0 and included configuration files. To obtain RDLS-SS-DWT v. 1.0, unpack rdls_ss_dwt_10.zip to the directory containing IRIS-JP3D v. 1.1.1 sources and apply the patch. E.g., using the GNU patch v. 2.5.9 (http://gnuwin32.sourceforge.net/packages/patch.htm) execute the following command: patch.exe -i jp3d_1_1_1.rdls_ss_dwt_10.patch. Description RDLS-SS-DWT+Pred was introduced to IRIS-JP3D v. 1.1.1 by altering its fdwt/idwt modules; other files were changed in a minimal extent mainly to enable compiling the sources using GCC/VS. RDLS-SS-DWT v. 1.0 configuration (subband filters to apply, steps to skip, settings for subband predictors, additional operations to perform during compression/decompression) must be defined beforehand in configuration file RS__transfpar.dat palced in the directory in where the RDLS-SS-DWT v. 1.0 is executed. Internal naming of denoising filters (e.g., in function names and comments in RS_vol_ops.c) is different to one used in [1, 2, 4, 5] (see below), having that in mind you may consult the commented sources for for additional informations. RDLS-SS-DWT v. 1.0 is internally controlled by a few variables and arrays: int fdwtOutputSave //save the FDWT output data as FDWTtransformed.raw, FDWTtransformed.descr, FDWTtransformed.PGM (for 3D processing save the first slice as PGM) ? int fdwtCalcEntropy //save the FDWT output data memoryless entropy of all subbands in file FDWTtransformed.H0 (see [1])? int fdwtEntropyPredictor //number of predictor to apply before computing entropy: 0-none, 1-AVG (obsolete), 2-MED (obsolete) int idwtInputSave //save the IDWT input data as IDWTuntransformed.raw, IDWTuntransformed.descr, IDWTuntransformed.PGM ? int dwtFindOrUsePredictors //find the best predictors for dwt subbands and apply them (fdwt) or undo decorrelation (idwt) int maxLevelDenoise //max transf. level at which denoising is performed, -1 for no denoising at all, levels are numbered from 0, if level>maxLevel then denoising is called, but uses the None filter int fdwtIsPredictorFixed[(MAX_LEVELS * 7) + 1 + 1 ] // valid if dwtFindOrUsePredictors==1; 0 - find predictor in fdwt using H0 estimation, 1 - use the predictor specified in fdwtFixedPredictor, i.e., the actual predictor and not the actualPredictors index // (see:RS_band_find_and_apply_predictor()) int fdwtFixedPredictor[(MAX_LEVELS * 7) + 1 + 1] // above tables are indexed with final dwt subband id's, which are ordered level after level, starting from level 0, ordering of final subbands for not top-level 3D decomposition: HLL, LHL, HHL, LLH, HLH, LHH, HHH; // top-level 3D decomposition: LLL, HLL, LHL, HHL, LLH, HLH, LHH, HHH; not top-level 2D decomposition: HL, LH, HH; top-level 2D decomposition: LL, HL, LH, HH; // e.g., for 4 levels in X,Y and 2 levels in Z (counting levels from 0): HLL0, LHL0, HHL0, LLH0, HLH0, LHH0, HHH0, HLL1, LHL1, HHL1, LLH1, HLH1, LHH1, HHH1, HL-2, LH-2, HH-2, LL-3, HL-3, LH-3, HH-3. const int actualPredictors[PREDICTORS_ALL] // numbers of predictors to use, to permit disabling certain predictors without needing to modify RS_predictor3d() (see:RS_band_find_and_apply_predictor()) // predNr: 0 - NOP - no prediction; // 1 - P1d_X : left; // 2 - P1d_Y : upper; // 3 - AVG_XY : in XY plane AVG: (left+upper)/2; // 4 - MED_XY : in XY plane MED: median(left, upper, left+upper-upper_left); // 5 - P1d_Z : above; // 6 - AVG_XZ : in XZ plane AVG // 7 - AVG_YZ : in YZ plane AVG // 8 - MED_XZ : in XZ plane MED // 9 - MED_YZ : in YZ plane MED // 10 - AVG3d : 3d: (left+upper+above)/3; int tranfSubbandDo[MAX_LEVELS][15] // perform or skip the FDWT/IDWT step for specific subband at specific level // MAX_LEVELS is the supported number of decomposition levels (5), level numbers start from 0, // [level][subbandId] == 1 perform DWT lifting step (e.g., just prediction or just update) resulting in creation of given subband, == 0 skip this step, // by default initialized to 1's, and changed based on transfParams, but may be set from RS__transfpar.dat // if the 2 complementary 1d DWT steps are skipped (e.g., 3 and 5, 7 and 11), reordering of coefficients is skipped as well in dwt_forward/inv_transform // no subbandId==0, any val. is ok., (1-14) subbands in 3D processing, (3,5,7,8,11,12) - subbands used in 2D mode. // subbandIds (also identified as GS- see Fig.2 and Table 1 in [4]): // 1: H subband computed using 1D-DWT in Z direction from entire volume (3D) // 2: L subband computed using 1D-DWT in Z direction from entire volume (3D) // 3: H subband computed using 1D-DWT in Y direction from samples from subband of subbandId 2 (3D), H subband in Fig. 1B in [1] (2D) // 4: H subband computed using 1D-DWT in Y direction from samples from subband of subbandId 1 (3D) // 5: L subband computed using 1D-DWT in Y direction from samples from subband of subbandId 2 (3D), L subband in Fig. 1B in [1] (2D) // 6: L subband computed using 1D-DWT in Y direction from samples from subband of subbandId 1 (3D) // 7: H subband computed using 1D-DWT in X direction from samples from subband of subbandId 5 (3D), HL subband in Fig. 1C in [1] (2D) // 8: H subband computed using 1D-DWT in X direction from samples from subband of subbandId 3 (3D), HH subband in Fig. 1C in [1] (2D) // 9: H subband computed using 1D-DWT in X direction from samples from subband of subbandId 6 (3D), // 10: H subband computed using 1D-DWT in X direction from samples from subband of subbandId 4 (3D), // 11: L subband computed using 1D-DWT in X direction from samples from subband of subbandId 5 (3D), LL subband in Fig. 1C in [1] (2D) // 12: L subband computed using 1D-DWT in X direction from samples from subband of subbandId 3 (3D), LH subband in Fig. 1C in [1] (2D) // 13: L subband computed using 1D-DWT in X direction from samples from subband of subbandId 6 (3D), // 14: L subband computed using 1D-DWT in X direction from samples from subband of subbandId 4 (3D), // assuming that no step skipping is employed, subbands of subbandId 1-6 are in given decomposition level further transformed and not available as the final result of this decomposition level int transfParams[MAX_LEVELS][15][7] // denoising filters (or step skipping modes) for given level and subband, and parameters of denoising filters, used by RS_vol_subband_denoise // transfParams array indexes are: [level][subband][param], levels are numbered from 0, subbands from 1 (so index 0 is ignored), // the 7 parameters for given level an subband, are: // 0-subbandId (must match row number) // 1-tt (internal name: transform type) denoising filter / step skipping mode // 2-6 denoising filter parameters // parameter 1 and 2-6 allowed values: // tt=0 - No denoising or skipping (None in [1]), which results in regular DWT lifting step, 2-6 ignore // tt=1 - Smoothing filter (see [1]), 2-rx (window width is 2rx+1), 3-ry (window height is 2ry+1), 4-rz (window depth is 2rz+1), 5-window center point weight, 6-weight of each not-center window point // tt=2 - Median filter (see [1]) 2-rx, 3-ry, 4-rz, 5-6 ignore // tt=3 - RCRS-1 filter (see [1]) (internally denoted: RCRS) 2-rx, 3-ry, 4-rz, 5-6 ignore // tt=4 - obsolete filter (internally denoted: RCRS2) 2-rx, 3-ry, 4-rz, 5-6 ignore // tt=5 - RCRS-2 filter (see [1]) (internally denoted: RCRS3) 2-rx, 3-ry, 4-rz, 5-6 ignore // tt=6 - Null-like filter returning 0 for all samples, for skipping the lifting step but without affecting the reorder step, used to test additional variants of SS-DWT BH (see [2]), 2-6 ignore // tt=100 - Null in [2, 5] - skip the step and if complementary step is skipped then the reorder will be skipped as well, basic mode for the SS-DWT, see [2] and bottom of initialize_RS_vol_ops // tt=101 - skip the step and its complementary step and reorder, used to test additional variants of SS-DWT BH (see [2]) and bottom of initialize_RS_vol_ops Configuration for RDLS-SS-DWT v. 1.0 is given in text file RS__transfpar.dat, below commands are recognized: 1001 // read maxLevelDenoise, should be followed by an intreger, -1 disables RDLS and SS 1002 // read fdwtOutputSave, should be followed by 0 or 1 1003 // read idwtInputSave, should be followed by 0 or 1 1004 // read fdwtCalcEntropy, should be followed by 0 or 1 1005 // read fdwtEntropyPredictor, should be followed by 0, 1, or 2 1010 // read transfParams, should be followed by MAX_LEVELSx15x7 integers 1011 // read 1st page of transfParams (parameters for DWT level 0), copy it to all other pages, should be followed by 15x7 integers 1012 // read given number N of transfParams pages, should be followed by an integer (N) and Nx15x7 integers 1020 // read tranfSubbandDo, should be followed by MAX_LEVELSx15 integers (allowed values 0 and 1) 1021 // read 1st row of tranfSubbandDo (parameters for DWT level 0), copy it to others 1022 // read given number of tranfSubbandDo rows 1030 // read dwtFindOrUsePredictors, should be followed by 0 or 1 1031 // read fdwtIsPredictorFixed and fdwtFixedPredictor, should be followed by MAX_LEVELSx7+1 integers (allowed values 0 and 1) and MAX_LEVELSx7+1 integers (allowed are values from actualPredictors table) 9999 // all done, comments etc. in RS__transfpar.dat may be placed after this command Remarks - RDLS-SS-DWT v. 1.0 was tested in various Windows enviroments using 64-bit executables compiled using MinGW-W64 v. 8.1.0 (see gcc64it.bat) and Microsoft VisualStudio 14 and 15 (Compile as C++ code and define: strtok_r=strtok_s;strcasecmp=_stricmp;strncasecmp=_strnicmp;_CRT_SECURE_NO_WARNINGS), - DWT modifications are implemented and tested for 5x3 kernel integer transforms, - Decomposition levels 0..5 are supported, the limit may be easily increased, thoroughly tested were 0 and 3-level decomposition, - version 0.9 was the initial one, it was used in [1, 2, 4], in v. 1.0 prediction was added, it was used in [5], - The following bug of original IRIS-JP3D v. 1.1.1 was probably fixed in RDLS-SS-DWT v. 1.0: when using higher levels of decomposition, JP3D sometimes triggered assertion: "(hlast >= 0) && (hlast < (MAX_POSSIBLE_PASSES + 1)), file t1.c, line 265", - The entire image was always compressed as a single tile, - RDLS-SS-DWT v. 1.0 was not optimized and should not be used for testing of speed; actually, the fdwt/idwt modules of IRIS-JP3D v. 1.1.1 were de-optimized prior to introducing RDLS and SS to them, - feel free to mail me (rstarosolski@polsl.pl, rstaros@gmail.com) in case of any questions or problems considering this software. References [1] Starosolski, R.: Application of reversible denoising and lifting steps to DWT in lossless JPEG 2000 for improved bitrates. Signal Processing: Image Communication, 2015, Vol. 39, Part A, pp. 249-63, DOI: 10.1016/j.image.2015.09.013, http://sun.aei.polsl.pl/~rstaros/papers/s2015-image-AAM.pdf. [2] Starosolski, R.: Skipping selected steps of DWT computation in lossless JPEG 2000 for improved bitrates. PLOS ONE, 2016, Vol. 11(12), pp. e0168704 (1-22), DOI: 10.1371/journal.pone.0168704, http://sun.aei.polsl.pl/~rstaros/papers/orig-s2016-plos-one.pdf. [3] Bruylants, T.; Munteanu, A.; Schelkens, P.: Wavelet based volumetric medical image compression. Signal Processing: Image Communication, 2015, vol. 31, pp. 112-133, DOI:10.1016/j.image.2014.12.007. [4] Starosolski, R.: Application of fixed skipped steps discrete wavelet transform in JP3D lossless compression of volumetric medical images. In: S. Kozielski et al. (Eds.): BDAS 2019. Springer CCIS, 2019, vol. 1018, pp. 217-30, DOI: 10.1007/978-3-030-19093-4_17, http://sun.aei.polsl.pl/~rstaros/papers/s2019-bdas-AAM.pdf. [5] Starosolski, R.: Hybrid adaptive lossless image compression based on discrete wavelet transform. (submitted).