Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need public function to tell kernel type used (5x3 vs 9x7) #3

Closed
gcode-importer opened this issue Jun 8, 2009 · 17 comments
Closed

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 3

 AFAIK j2k.h and jp2.h header files are not installed on a standard
openjpeg installation. Is this intended ?
  Here is the issue I am currently facing, in order to reject lossy
JP2/J2K stream in clinical trial environment I had to code the
following:

  int reversible;
  opj_j2k_t* j2k = NULL;
  opj_jp2_t* jp2 = NULL;

  switch(parameters.decod_format)
    {
  case J2K_CFMT:
    j2k = (opj_j2k_t*)dinfo->j2k_handle;
    assert( j2k );
    reversible = j2k->cp->tcps->tccps->qmfbid;
    break;
  case JP2_CFMT:
    jp2 = (opj_jp2_t*)dinfo->jp2_handle;
    assert( jp2 );
    reversible = jp2->j2k->cp->tcps->tccps->qmfbid;
    break;
  default:
    gdcmErrorMacro( "Impossible happen" );
    return false;
    }
  LossyFlag = !reversible;

Unfortunately I need to include j2k.h  / jp2.h which is completely
non-standard on linux distribution.

What other people recommend for this situation:

- Extend openjpeg installation mechanism to install j2k.h / jp2.h
- Extend openjpeg.h API to return the reversible flag.

Thanks for suggestion 

Reported by malaterre on 2009-06-08 08:33:41

@gcode-importer
Copy link
Author

Ref:
http://groups.google.com/group/openjpeg/browse_thread/thread/7c80e293e80fa931

Reported by malaterre on 2009-06-08 08:33:52

@gcode-importer
Copy link
Author

Issue is still current in 2012:
http://groups.google.com/group/openjpeg/browse_thread/thread/af13483b979b77b8

Reported by malaterre on 2012-01-11 19:11:31

  • Status changed: Accepted
  • Labels added: Priority-High
  • Labels removed: Priority-Medium

@gcode-importer
Copy link
Author

Following the norm, each tile-component can be coded with is own transformation (reversible
or irreversible) so is quite difficult to have one unique function: cf markers COD
and COC

Reported by savmickael on 2012-11-13 12:58:30

@gcode-importer
Copy link
Author

Reported by malaterre on 2014-02-25 15:19:50

  • Labels added: Priority-Low
  • Labels removed: Priority-High

@gcode-importer
Copy link
Author

Reported by malaterre on 2014-02-27 08:04:29

  • Labels added: Milestone-Release2.1

@gcode-importer
Copy link
Author

Reported by savmickael on 2014-03-06 11:43:54

@gcode-importer
Copy link
Author

Creating a fake irreversible image:

$ kdu_compress -no_info -i lena512.pgm -o lena512.j2k Ckernels:T0C0=W5X3

Reported by malaterre on 2014-03-14 13:11:34

@gcode-importer
Copy link
Author

This issue was updated by revision r2740.

Reported by malaterre on 2014-03-14 13:53:47

@gcode-importer
Copy link
Author

Funky one:
$ kdu_compress -no_info -i lena512.pgm -o lena512.j2k Ckernels:T2C0=W9X7 "Stiles={256,256}"
Ckernels:T1C0=W5X3

Reported by malaterre on 2014-03-14 13:54:29

@gcode-importer
Copy link
Author

More fun:
$ kdu_compress -no_info -i lena512.pgm -o lena512.j2k Ckernels:T2C0=W9X7 "Stiles={256,256}"
Ckernels:T1C0=W5X3 Clevels:T1C0=0 Cuse_sop:T2=yes Cprecincts:T0="{128,128}"

Reported by malaterre on 2014-03-14 14:00:17

@gcode-importer
Copy link
Author

Reported by malaterre on 2014-03-14 14:02:38

  • Labels removed: Milestone-Release2.1

@malaterre
Copy link
Collaborator

I used to have the following code on my local openjpeg version in GDCM:

int j2k_get_reversible(
  opj_j2k_t * p_j2k)
{
  opj_cp_t *cp = 00;
  cp = &(p_j2k->m_cp);
  return cp->tcps->tccps->qmfbid;
}
int jp2_get_reversible(
  opj_jp2_t * p_jp2)
{
  return j2k_get_reversible(p_jp2->j2k);
}

int OPJ_CALLCONV opj_get_reversible(opj_codec_t *p_info, opj_dparameters_t *parameters)
{
  int ret = -1;
  if (p_info)
    {
    opj_codec_private_t * l_info = (opj_codec_private_t *) p_info;
    if (l_info->is_decompressor)
      {
      switch(parameters->decod_format)
        {
      case 0: // J2K_CFMT:
        ret = j2k_get_reversible(l_info->m_codec);
        break;
      case 1: // JP2_CFMT:
        ret = jp2_get_reversible(l_info->m_codec);
        break;
        }
      }
    }
  return ret;
}

@malaterre
Copy link
Collaborator

One may need to adapt the suggested code to loop over all tiles.

@malaterre
Copy link
Collaborator

Not having such functions prevents me from switching from OPJ 1.5 to OPJ 2.1 see ref: https://sourceforge.net/p/gdcm/bugs/356/

@malaterre
Copy link
Collaborator

The longer story is that (usual UNIX stuff) programs are now being compiled against opj 1.5 and somewhere deep down in the dep chains, another lib is compiled against opj 2.1 (different ABI). This may become a very serious issue in the not so distant future.

@malaterre
Copy link
Collaborator

As a side note, I would also be required to expose the MCT (COD) flag also. This helps DICOM encapsulation where knowing the transformation is required.

@rouault
Copy link
Collaborator

rouault commented Sep 2, 2017

This information is available through the use of opj_get_cstr_info(). Admitedly this is just for the default coding parameters, not per-tile. But deciding the filter per-tile is rather unusual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants