VintaSoft Imaging .NET SDK v8.7
In This Topic
    PDF: Use MRC compression for encoding PDF document
    In This Topic

    1. General principles and applicability of MRC compression

    MRC (Mixed Raster Content) compression - a technology for compressing color image by separating image into layers with essentially different characteristics. Based on characteristics of layer the layer is compressed using the most efficient and accurate compression algorithm.

    The best method to achieve the highest compression ratio while maintaining acceptable quality is the compression of different image areas according to their individual characteristics. Bi-level details associated with text and line-art graphics would be compressed with an approach that puts high emphasis on maintaining the detail and structure of the input images. Continuous-tone images and multi-level continuous-tone colors would be compressed with an approach that puts high emphasis on maintaining the smoothness and accuracy of the colors.

    Here is an example that demonstrates how the image is separated into layers using MRC compression algorithm:
    Example that demonstrates how image separated into layers using MRC compression algorithm
    MRC compression is applicable for color images only and it is ideal for compressing scanned color documents. Compression works efficiently for color document images with text, line-art graphics and full-color images. MRC compression uses different compression algorithms for different kind of graphics and this gives the best compression results unlike the situation when just one compression algorithm is applied to the whole image.


    2. Using MRC compression for encoding images to PDF format

    MRC compression is used for encoding one or more color images to PDF format. The introduced algorithm provides lossy compression.

    Vintasoft.Imaging.Pdf.Mrc.dll assembly contains classes responsible for image encoding in PDF using MRC compression:

    PdfMrcCompressionSettings.EnableMrcCompression property specifies that MRC compression must be used for encoding image to a PDF format. False value means that PdfMrcEncoder class will perform image encoding using methods of basic PdfEncoder class, i.e. using common (image-only) compression algorithm.

    The following plug-ins are mandatory for using MRC compression:

    The following plug-ins are recommended for getting the best compression and quality results:

    The following example demonstrates how to encode an image collection to a PDF document using MRC compression:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.DocCleanup
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub EncodeImagesUseMrc(images As Vintasoft.Imaging.ImageCollection, pdfFilename As String)
            ' create PDF MRC encoder
            Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder()
    
            ' set MRC compression settings
            SetCompressionSettings(encoder.MrcCompressionSettings)
    
            ' save images to PDF use MRC compression
            images.SaveSync(pdfFilename, encoder)
    End Sub
    
    Private Shared Sub SetCompressionSettings(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            ' background layer
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 35
    
            ' images layer, images placed to background layer
            settings.ImageSegmentation = New Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand()
            settings.CreateImagesLayer = False
    
            ' mask layer
            settings.HiQualityMask = True
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            ' front layer
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = True
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.FrontLayerCompressionSettings.JpegQuality = 25
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.DocCleanup
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void EncodeImagesUseMrc(Vintasoft.Imaging.ImageCollection images, string pdfFilename)
    {
        // create PDF MRC encoder
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder encoder = 
            new Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder();
        
        // set MRC compression settings
        SetCompressionSettings(encoder.MrcCompressionSettings);
        
        // save images to PDF use MRC compression
        images.SaveSync(pdfFilename, encoder);
    }
    
    private static void SetCompressionSettings(Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        // background layer
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 35;
    
        // images layer, images placed to background layer
        settings.ImageSegmentation = 
            new Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand();
        settings.CreateImagesLayer = false;
    
        // mask layer
        settings.HiQualityMask = true;
        settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        // front layer
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = true;
        settings.FrontLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.FrontLayerCompressionSettings.JpegQuality = 25;
    }
                    
    


    2.1. Layers and algorithms used in MRC compression

    MRC compression uses four layers:
    Layers used in MRC compression


    Parameters and compression algorithm for each layer are specified individually, each layer can be disabled.

    The following additional algorithms are used for analyzing the source image:


    2.2. Compression settings for Background layer

    The following properties define how to compose and compress the Background layer:

    The background layer generally stores not very important information, that's why is recommended to compress it using the lossy compression algorithms such as Jpeg+ZIP or Jpeg2000.


    2.3. Compression settings for Images layer

    The following properties define how to compose and compress the Images layer:

    The processing and searching for full-color images can be disabled by setting the value of PdfMrcCompressionSettings.ImageSegmentation and PdfMrcCompressionSettings.ImageRegions property to null.

    The Images layer stores full-color images, that's why is recommended to compress it using the algorithms Jpeg+ZIP or Jpeg2000 with acceptable loss in quality.

    Important! If the PdfMrcCompressionSettings.CreateImagesLayer property value is set to False (full-color images are placed onto Background layer) then the quality of encoded images can be managed using the compression settings of Background layer: PdfMrcCompressionSettings.BackgroundLayerCompression, PdfMrcCompressionSettings.BackgroundLayerCompressionSettings.

    ImageSegmentationCommand has various settings allowing to set up the quality, sensitivity and accuracy of search for full-color images.


    2.4. Compression settings for Mask layer

    The following properties define how to compose and compress the Mask layer:

    Important! The rectangle which is recognized as full-color image will be excluded from Mask layer (ref. to PdfMrcCompressionSettings.ImageRegions and PdfMrcCompressionSettings.ImageSegmentation properties).

    By default, the image binarization with automatic threshold detection is used for composing the mask layer and in most cases it provides good compression results. For getting the best compression results the different binarization algorithms should be used for different types of document images.

    The mask layer stores a black-white image, that's why is recommend to compress it using the Jbig2 or CCITT compression algorithm.


    2.5. Compression settings for Front layer

    The following properties define how to compose and compress the Front layer:

    Front layer stores a palette image, that's why it could be compressed using ZIP algorithm. However, in case when text has a wide variety of different colors or there is applied a high color resolution (PdfMrcCompressionSettings.HiQualityFrontLayer), then the best results with acceptable loss in quality give Jpeg+ZIP or Jpeg2000 compression algorithms.


    2.6. Recommended MRC compression settings for different types of document images.

    Document images may be classified by following criteria:

    Here is an example that shows how to compress the document images, which contain text and pictures, using MRC compression algorithm and get the resulting images with high quality:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.DocCleanup
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentWithImagesHiQuality(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 60
    
            settings.ImageSegmentation = New Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand()
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = True
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = True
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 300 * 3
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.DocCleanup
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentWithImagesHiQuality(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 60;
    
        settings.ImageSegmentation =
            new Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand();
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = true;
        settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = true;
        settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 300 * 3;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = 
            Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy;
    }
                    
    

    Here is an example that shows how to compress the document images, which contain text and pictures, using MRC compression algorithm and get the resulting images with normal quality:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.DocCleanup
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentWithImagesNormal(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 35
    
            settings.ImageSegmentation = New Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand()
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = True
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = True
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.FrontLayerCompressionSettings.JpegQuality = 25
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 400 * 3
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.DocCleanup
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentWithImagesNormal(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 35;
    
        settings.ImageSegmentation = 
            new Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand();
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = true;
        settings.MaskCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = true;
        settings.FrontLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.FrontLayerCompressionSettings.JpegQuality = 25;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 400 * 3;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = 
            Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy;
    }
                    
    

    Here is an example that shows how to compress the document images, which contain text and pictures, using MRC compression algorithm and get the resulting images with high compression ratio:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.DocCleanup
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentWithImagesHiCompression(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 20
    
            settings.ImageSegmentation = New Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand()
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = False
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = False
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.DocCleanup
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentWithImagesHiCompression(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 20;
    
        settings.ImageSegmentation = 
            new Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand();
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = false;
        settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = false;
        settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip;
    }
                    
    

    Here is an example that shows how to compress the document images, which contain text only, using MRC compression algorithm and get the resulting images with high quality:
    Document images which do not contain full-color images, high quality:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentNoImagesHiQuality(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 30
    
            settings.ImageSegmentation = Nothing
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = True
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = True
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 300 * 3
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentNoImagesHiQuality(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 30;
    
        settings.ImageSegmentation = null;
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = true;
        settings.MaskCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = true;
        settings.FrontLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 300 * 3;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = 
            Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy;
    }
                    
    

    Here is an example that shows how to compress the document images, which contain text only, using MRC compression algorithm and get the resulting images with normal quality:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentNoImagesNormal(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 25
    
            settings.ImageSegmentation = Nothing
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = True
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = False
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 350 * 3
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentNoImagesNormal(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 25;
    
        settings.ImageSegmentation = null;
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = true;
        settings.MaskCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = false;
        settings.FrontLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 350 * 3;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = 
            Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy;
    }
                    
    

    Here is an example that shows how to compress the document images, which contain text only, using MRC compression algorithm and get the resulting images with high compression ratio:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    ' - Vintasoft.Imaging.Pdf.Mrc
    
    Public Shared Sub SetSetting_DocumentNoImagesHiCompression(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
            settings.CreateBackgroundLayer = True
            settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
            settings.BackgroundLayerCompressionSettings.JpegQuality = 20
    
            settings.ImageSegmentation = Nothing
            settings.CreateImagesLayer = False
    
            settings.HiQualityMask = False
            settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
            settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
    
            settings.CreateFrontLayer = True
            settings.HiQualityFrontLayer = False
            settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 450 * 3
            settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    // - Vintasoft.Imaging.Pdf.Mrc
    
    public static void SetSetting_DocumentNoImagesHiCompression(
        Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
    {
        settings.CreateBackgroundLayer = true;
        settings.BackgroundLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | 
            Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        settings.BackgroundLayerCompressionSettings.JpegQuality = 20;
    
        settings.ImageSegmentation = null;
        settings.CreateImagesLayer = false;
    
        settings.HiQualityMask = false;
        settings.MaskCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
        settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
    
        settings.CreateFrontLayer = true;
        settings.HiQualityFrontLayer = false;
        settings.FrontLayerCompression = 
            Vintasoft.Imaging.Pdf.PdfCompression.Jpeg2000;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionRatio = 450 * 3;
        settings.FrontLayerCompressionSettings.Jpeg2000Settings.CompressionType = 
            Vintasoft.Imaging.Codecs.ImageFiles.Jpeg2000.Jpeg2000CompressionType.Lossy;
    }
                    
    


    3. Compression examples. Visual comparison of compression quality.

    This visual comparison of compression quality was performed using 4 different images:

    The testing was executed as follows: for document images without full-color pictures were used the compression settings like for -Document images which do not contain full-color pictures, normal quality-, for document images with full-color images like for -Document images which contain full-color pictures, normal quality- (see section 2.6).
    After the MRC compression with chosen settings was applied, the source images were compressed using JPEG and JPEG2000 codecs so that to conform the size of compressed source files with the size of MRC compressed file.


    Comparison of compressed image fragments: rasterized_noImages, 42.79MB uncompressed:

    PNG
    3.664MB
    1:12
    PDF MRC
    0.246MB
    1:174
    JPEG2000
    0.252MB
    1:170
    JPEG
    0.379MB
    1:113


    Comparison of compressed image fragments: rasterized_withImages, 20.13MB uncompressed:

    PNG
    3.472MB
    1:6
    PDF MRC
    0.144MB
    1:139
    JPEG2000
    0.147MB
    1:137
    JPEG
    0.170MB
    1:118


    Comparison of compressed image fragments: scanned_noImages, 36.93MB uncompressed:

    PNG
    4.639MB
    1:8
    PDF MRC
    0.205MB
    1:180
    JPEG2000
    0.205MB
    1:180
    JPEG
    0.212MB
    1:174


    Comparison of compressed image fragments: scanned_withImages, 6.61MB uncompressed:

    PNG
    2.75MB
    1:2.4
    PDF MRC
    0.112MB
    1:59
    JPEG2000
    0.114MB
    1:58
    JPEG
    0.118MB
    1:56