public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImagingException {
        try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed);
                BitInputStreamFlexible inputStream = new BitInputStreamFlexible(baos);
                BitArrayOutputStream outputStream = new BitArrayOutputStream()) {
            for (int y = 0; y < height; y++) {
                int color = WHITE;
                int rowLength;
                for (rowLength = 0; rowLength < width;) {
                    final int runLength = readTotalRunLength(inputStream, color);
                    for (int i = 0; i < runLength; i++) {
                        outputStream.writeBit(color);
                    }
                    color = 1 - color;
                    rowLength += runLength;
                }

                if (rowLength == width) {
                    inputStream.flushCache();
                    outputStream.flush();
                } else if (rowLength > width) {
                    throw new ImagingException("Unrecoverable row length error in image row " + y);
                }
            }
            return outputStream.toByteArray();
        } catch (final IOException ioException) {
            throw new ImagingException("Error reading image to decompress", ioException);
        }
    }
Decompresses the "Modified Huffman" encoding of section 10 in the TIFF6 specification. No EOLs, no RTC, rows are padded to end on a byte boundary.

@param compressed compressed byte data
@param width      image width
@param height     image height
@return the compressed data
@throws ImagingException if it fails to read the compressed data
src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java