Main Content


Read blocks of JPEG2000 files

Since R2023a


    The JPEG2000 object is an adapter that reads 2-D blocked image data in the JPEG2000 format.

    By default, the object reads JPEG2000 image files with a block size of [1024 1024]. To use a different block size, create the object and then change the block size using the IOBlockSize property. For example, to specify a block size of [512 512], use this code.

    adapter = images.blocked.JPEG2000;
    adapter.IOBlockSize = [512 512];

    The table lists the support that the JPEG2000 object has for various blockedImage capabilities.

    Data types

    This object supports 2-D images only:

    • Binary images of size m-by-n with data type logical

    • Grayscale images of size m-by-n with data type uint8, int8, uint16, and int16

    • Truecolor (RGB) images of size m-by-n-by-3 with data type uint8

    Multiple resolution levelsYes
    Process blocks in parallel using the apply functionYes
    Resume block processing using the apply functionNo
    Write blocked image data using the write functionNo




    adapter = images.blocked.JPEG2000 creates a JPEG2000 object that reads blocks from JPEG2000 files.


    expand all

    Block size for reading, specified as a numeric vector.


    collapse all

    Create a JPEG2000 adapter that reads blocks of size 64-by-64 pixels.

    readAdapter = images.blocked.JPEG2000;
    readAdapter.IOBlockSize = [64 64]
    readAdapter = 
      JPEG2000 with properties:
        IOBlockSize: [64 64]

    Create a blocked image that reads a JPEG2000 image using the adapter.

    bim = blockedImage("lighthouse.jp2",Adapter=readAdapter);

    Display the size of the blocked image at each resolution level.

    ans = 5×3
       640   480     3
       320   240     3
       160   120     3
        80    60     3
        40    30     3

    Display the I/O block size at each resolution level.

    ans = 5×3
        64    64     3
        64    64     3
        64    64     3
        64    64     3
        64    64     3

    Version History

    Introduced in R2023a