←Select platform

CodecsJpeg2000PrecinctSize Enumeration

Summary
Values to specify the size of JPEG 2000 compressed packets, provides a mean of random access into a JPEG 2000 compressed stream.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public enum CodecsJpeg2000PrecinctSize   
typedef NS_ENUM(NSInteger, LTCodecsJpeg2000PrecinctSize) { 
 LTCodecsJpeg2000PrecinctSizeFull = 0,  
 LTCodecsJpeg2000PrecinctSizeUniform64 = 1,  
 LTCodecsJpeg2000PrecinctSizeUniform128 = 2,  
 LTCodecsJpeg2000PrecinctSizeUniform256 = 3,  
 LTCodecsJpeg2000PrecinctSizeUniform512 = 4,  
 LTCodecsJpeg2000PrecinctSizeUniform1024 = 5,  
 LTCodecsJpeg2000PrecinctSizeUniform2048 = 6,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalOne64 = 7,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalOne128 = 8,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalOne256 = 9,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalOne512 = 10,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalTwo64 = 11,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalTwo128 = 12,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalTwo256 = 13,  
 LTCodecsJpeg2000PrecinctSizeHierarchicalTwo512 = 14 
}; 
public enum CodecsJpeg2000PrecinctSize 
public enum class CodecsJpeg2000PrecinctSize   
class CodecsJpeg2000PrecinctSize(Enum): 
   Full = 0 
   Uniform64 = 1 
   Uniform128 = 2 
   Uniform256 = 3 
   Uniform512 = 4 
   Uniform1024 = 5 
   Uniform2048 = 6 
   HierarchicalOne64 = 7 
   HierarchicalOne128 = 8 
   HierarchicalOne256 = 9 
   HierarchicalOne512 = 10 
   HierarchicalTwo64 = 11 
   HierarchicalTwo128 = 12 
   HierarchicalTwo256 = 13 
   HierarchicalTwo512 = 14 
Members
ValueMemberDescription
0FullNo precinct is used, size is infinite.
1Uniform64For all resolution levels, a precinct dimension of [64x64] will be applied.
2Uniform128For all resolution levels, a precinct dimension of [128x128] will be applied.
3Uniform256For all resolution levels, a precinct dimension of [256x256] will be applied.
4Uniform512For all resolution levels, a precinct dimension of [512x512] will be applied.
5Uniform1024For all resolution levels, a precinct dimension of [1024x1024] will be applied.
6Uniform2048For all resolution levels, a precinct dimension of [2048x2048] will be applied.
7HierarchicalOne64A precinct size of [X by X] will be applied to the first(smallest) resolution of the image. The second resolution precinct dimension would be [2X by 2X]. The third resolution precinct dimension would be [4X by 4X] and so on. If the JPEG 2000 file has five levels and HierarchicalOne64 is used, the precinct dimensions will be as follows:
  • [64x64] level 1
  • [128x128] level 2
  • [256x256] level 3
  • [512x512] level 4
  • [1024x1024] level 5

8HierarchicalOne128A precinct size of [X by X] will be applied to the first(smallest) resolution of the image. The second resolution precinct dimension would be [2X by 2X]. The third resolution precinct dimension would be [4X by 4X] and so on. If the JPEG 2000 file has five levels and HierarchicalOne128 is used, the precinct dimensions will be as follows:
  • [128x128] level 1
  • [256x256] level 2
  • [512x512] level 3
  • [1024x1024] level 4
  • [2048x2048] level 5

9HierarchicalOne256A precinct size of [X by X] will be applied to the first(smallest) resolution of the image. The second resolution precinct dimension would be [2X by 2X]. The third resolution precinct dimension would be [4X by 4X] and so on. If the JPEG 2000 file has five levels and HierarchicalOne256 is used, the precinct dimensions will be as follows:
  • [256x256] level 1
  • [512x512] level 2
  • [1024x1024] level 3
  • [2048x2048] level 4
  • [4096x4096] level 5

10HierarchicalOne512A precinct size of [X by X] will be applied to the first(smallest) resolution of the image. The second resolution precinct dimension would be [2X by 2X]. The third resolution precinct dimension would be [4X by 4X] and so on. If the JPEG 2000 file has five levels and HierarchicalOne512 is used, the precinct dimensions will be as follows:
  • [512x512] level 1
  • [1024x1024 level 2
  • [2048x2048] level 3
  • [4096x4096] level 4
  • [8192x8192] level 5

11HierarchicalTwo64A precinct size of [X by X] will be applied to the first and second (smallest) resolutions of the image. The third and fourth resolution precinct dimensions would be [2X by 2X] and so on. So if the JPEG 2000 file has five levels and HierarchicalTwo64 is used, the precinct dimensions will be as follows:
  • [64x64] level 1
  • [64x64] level 2
  • [128x128] level 3
  • [128x128] level 4
  • [256x256] level 5

12HierarchicalTwo128A precinct size of [X by X] will be applied to the first and second (smallest) resolutions of the image. The third and fourth resolution precinct dimensions would be [2X by 2X] and so on. So if the JPEG 2000 file has five levels and HierarchicalTwo128 is used, the precinct dimensions will be as follows:
  • [128x128] level 1
  • [128x128] level 2
  • [256x256] level 3
  • [256x256] level 4
  • [512x512] level 5

13HierarchicalTwo256A precinct size of [X by X] will be applied to the first and second (smallest) resolutions of the image. The third and fourth resolution precinct dimensions would be [2X by 2X] and so on. So if the JPEG 2000 file has five levels and HierarchicalTwo256 is used, the precinct dimensions will be as follows:
  • [256x256] level 1
  • [256x256] level 2
  • [512x512] level 3
  • [512x512] level 4
  • [1024x1024] level 5

14HierarchicalTwo512A precinct size of [X by X] will be applied to the first and second (smallest) resolutions of the image. The third and fourth resolution precinct dimensions would be [2X by 2X] and so on. So if the JPEG 2000 file has five levels and HierarchicalTwo512 is used, the precinct dimensions will be as follows:
  • [512x512] level 1
  • [512x512] level 2
  • [1024x1024] level 3
  • [1024x1024] level 4
  • [2048x2048] level 5

Remarks

Precincts are rectangular regions in the wavelet domain, within a given resolution level and image component that represent a spatial region on the image. They are used for limiting the size of JPEG 2000 compressed packets and to provide a means of random access into a JPEG 2000 compressed stream. For this reason, they should be used for interactive transfer of JPEG 2000 files as in JPIP applications. In general, dividing the image into precincts is better than tiling it. So it is recommended that users compress the image as one tile and use precincts to divide the spatial region. This will give better compression ratios and image quality. Using smaller precinct dimensions provides finer access to the compressed stream yet increases the compressed stream size. It is recommended to use HierarchicalOne128 and no tiling to generate JPEG 2000 files for any purpose.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
using Leadtools.Pdf; 
 
public void CodecsJpeg2000OptionsExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k"); 
 
   CodecsJpeg2000PrecinctSize[] precintSizes = (CodecsJpeg2000PrecinctSize[])Enum.GetValues(typeof(CodecsJpeg2000PrecinctSize)); 
   foreach (var precinctSize in precintSizes) 
   { 
      Console.WriteLine($"PrecinctSize types: {precinctSize}"); 
   } 
 
   //Setting the Jpeg2000 load options. CodecsJpeg2000Options & CodecsJpeg2000LoadOptions reference 
   codecs.Options.Jpeg2000.Load.J2kResolution = new LeadSize(800, 800); 
   codecs.Options.Jpeg2000.Load.Jp2Resolution = new LeadSize(800, 800); 
   codecs.Options.Jpeg2000.Load.CmwResolution = new LeadSize(0, 0); 
 
   //loading a Jpeg2000 image. 
   RasterImage srcImage = codecs.Load(srcFileName); 
 
   //Setting the Jpeg2000 save options. CodecsJpeg2000SaveOptions reference 
   codecs.Options.Jpeg2000.Save.AlphaChannelActiveBits = 16; 
   codecs.Options.Jpeg2000.Save.AlphaChannelLossless = false; 
   codecs.Options.Jpeg2000.Save.CompressionControl = CodecsJpeg2000CompressionControl.Ratio; 
   codecs.Options.Jpeg2000.Save.CompressionRatio = 15.0f; 
   codecs.Options.Jpeg2000.Save.DecompositionLevels = 5; 
   codecs.Options.Jpeg2000.Save.DerivedQuantization = true; 
   codecs.Options.Jpeg2000.Save.ImageAreaHorizontalOffset = 0; 
   codecs.Options.Jpeg2000.Save.ImageAreaVerticalOffset = 0; 
   codecs.Options.Jpeg2000.Save.ProgressingOrder = CodecsJpeg2000ProgressionsOrder.PositionComponentResolutionLayer; 
   codecs.Options.Jpeg2000.Save.PrecinctSize = CodecsJpeg2000PrecinctSize.HierarchicalOne64; 
   codecs.Options.Jpeg2000.Save.ReferenceTileHeight = 240; 
   codecs.Options.Jpeg2000.Save.ReferenceTileWidth = 480; 
   codecs.Options.Jpeg2000.Save.RegionOfInterest = CodecsJpeg2000RegionOfInterest.UseLeadRegion; 
   codecs.Options.Jpeg2000.Save.RegionOfInterestRectangle = new LeadRect(0, 0, 0, 0); 
   codecs.Options.Jpeg2000.Save.TargetFileSize = 10240; 
   codecs.Options.Jpeg2000.Save.TileHorizontalOffset = 0; 
   codecs.Options.Jpeg2000.Save.TileVerticalOffset = 0; 
   codecs.Options.Jpeg2000.Save.UseColorTransform = true; 
   codecs.Options.Jpeg2000.Save.UseEphMarker = false; 
   codecs.Options.Jpeg2000.Save.UseRegionOfInterest = false; 
   codecs.Options.Jpeg2000.Save.UseSopMarker = false; 
 
   //Save the first sample. 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "Image1_test.j2k"), RasterImageFormat.J2k, srcImage.BitsPerPixel); 
   codecs.Options.Jpeg2000.Save.Reset(); 
 
   //changing some of the Jpeg2000 save options 
   codecs.Options.Jpeg2000.Save.CompressionRatio = 23.0f; 
   codecs.Options.Jpeg2000.Save.DecompositionLevels = 6; 
   codecs.Options.Jpeg2000.Save.ReferenceTileHeight = 320; 
   codecs.Options.Jpeg2000.Save.ReferenceTileWidth = 320; 
   codecs.Options.Jpeg2000.Save.UseEphMarker = true; 
   codecs.Options.Jpeg2000.Save.ProgressingOrder = CodecsJpeg2000ProgressionsOrder.ResolutionPositionComponentLayer; 
   codecs.Options.Jpeg2000.Save.UseSopMarker = true; 
   codecs.Options.Jpeg2000.Save.TargetFileSize = 102400; 
 
   var maximumComponentsNumber = CodecsJpeg2000SaveOptions.MaximumComponentsNumber; 
   var maximumDecompressionLevels = CodecsJpeg2000SaveOptions.MaximumDecompressionLevels; 
   Console.WriteLine("MaximumComponents: {0}, MaximumDecompressionLevels: {1}", maximumComponentsNumber, maximumDecompressionLevels); 
 
   //Save the first sample. 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "Image1_test.jp2"), RasterImageFormat.J2k, srcImage.BitsPerPixel); 
 
   // Clean up 
   srcImage.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.nio.file.Paths; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.MinMaxBitsCommand; 
 
 
public void codecsJpeg2000OptionsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
   String srcFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1.j2k"); 
   CodecsJpeg2000PrecinctSize[] precinctSizes = CodecsJpeg2000PrecinctSize.values(); 
   System.out.println(precinctSizes.toString()); 
 
   // Setting the Jpeg2000 load options. CodecsJpeg2000Options & 
   // CodecsJpeg2000LoadOptions reference 
   codecs.getOptions().getJpeg2000().getLoad().setJ2kResolution(new LeadSize(800, 800)); 
   codecs.getOptions().getJpeg2000().getLoad().setJp2Resolution(new LeadSize(800, 800)); 
   codecs.getOptions().getJpeg2000().getLoad().setCmwResolution(new LeadSize(0, 0)); 
 
   // loading a Jpeg2000 image. 
   RasterImage srcImage = codecs.load(srcFileName); 
 
   // Setting the Jpeg2000 save options. CodecsJpeg2000SaveOptions reference 
   codecs.getOptions().getJpeg2000().getSave().setAlphaChannelActiveBits(16); 
   codecs.getOptions().getJpeg2000().getSave().setAlphaChannelLossless(false); 
   codecs.getOptions().getJpeg2000().getSave().setCompressionControl(CodecsJpeg2000CompressionControl.RATIO); 
   codecs.getOptions().getJpeg2000().getSave().setCompressionRatio(15.0f); 
   codecs.getOptions().getJpeg2000().getSave().setDecompositionLevels(5); 
   codecs.getOptions().getJpeg2000().getSave().setDerivedQuantization(true); 
   codecs.getOptions().getJpeg2000().getSave().setImageAreaHorizontalOffset(0); 
   codecs.getOptions().getJpeg2000().getSave().setImageAreaVerticalOffset(0); 
   codecs.getOptions().getJpeg2000().getSave() 
         .setProgressingOrder(CodecsJpeg2000ProgressionsOrder.POSITION_COMPONENT_RESOLUTION_LAYER); 
   codecs.getOptions().getJpeg2000().getSave().setPrecinctSize(CodecsJpeg2000PrecinctSize.HIERARCHICAL_ONE_64); 
   codecs.getOptions().getJpeg2000().getSave().setReferenceTileHeight(240); 
   codecs.getOptions().getJpeg2000().getSave().setReferenceTileWidth(480); 
   codecs.getOptions().getJpeg2000().getSave().setRegionOfInterest(CodecsJpeg2000RegionOfInterest.USE_LEAD_REGION); 
   codecs.getOptions().getJpeg2000().getSave().setRegionOfInterestRectangle(new LeadRect(0, 0, 0, 0)); 
   codecs.getOptions().getJpeg2000().getSave().setTargetFileSize(10240); 
   codecs.getOptions().getJpeg2000().getSave().setTileHorizontalOffset(0); 
   codecs.getOptions().getJpeg2000().getSave().setTileVerticalOffset(0); 
   codecs.getOptions().getJpeg2000().getSave().setUseColorTransform(true); 
   codecs.getOptions().getJpeg2000().getSave().setUseEphMarker(false); 
   codecs.getOptions().getJpeg2000().getSave().setUseRegionOfInterest(false); 
   codecs.getOptions().getJpeg2000().getSave().setUseSopMarker(false); 
 
   // Save the first sample. 
   codecs.save(srcImage, combine(LEAD_VARS_IMAGES_DIR, "Image1_test.j2k"), RasterImageFormat.J2K, 
         srcImage.getBitsPerPixel()); 
   codecs.getOptions().getJpeg2000().getSave().reset(); 
 
   // changing some of the Jpeg2000 save options 
   codecs.getOptions().getJpeg2000().getSave().setCompressionRatio(23.0f); 
   codecs.getOptions().getJpeg2000().getSave().setDecompositionLevels(6); 
   codecs.getOptions().getJpeg2000().getSave().setReferenceTileHeight(320); 
   codecs.getOptions().getJpeg2000().getSave().setReferenceTileWidth(320); 
   codecs.getOptions().getJpeg2000().getSave().setUseEphMarker(true); 
   codecs.getOptions().getJpeg2000().getSave() 
         .setProgressingOrder(CodecsJpeg2000ProgressionsOrder.RESOLUTION_POSITION_COMPONENT_LAYER); 
   codecs.getOptions().getJpeg2000().getSave().setUseSopMarker(true); 
   codecs.getOptions().getJpeg2000().getSave().setTargetFileSize(102400); 
   CodecsJpeg2000SaveOptions csSaveOptions = new CodecsJpeg2000SaveOptions(null); 
   var maximumComponentsNumber = csSaveOptions.getMaximumComponentsNumber(); 
   var maximumDecompressionLevels = csSaveOptions.getMaximumDecompressionLevels(); 
   System.out.println("MaximumComponents: " + maximumComponentsNumber + ", MaximumDecompressionLevels: " 
         + maximumDecompressionLevels); 
 
   // Save the first sample. 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1_test.jp2"); 
   codecs.save(srcImage, outputFileName, RasterImageFormat.J2K, srcImage.getBitsPerPixel()); 
 
   assertTrue("File unsuccessfully saved to " + outputFileName, (new File(outputFileName)).exists()); 
   System.out.printf("File successfully saved to %s%n", outputFileName); 
 
   // Clean up 
   srcImage.dispose(); 
   codecs.dispose(); 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Codecs Namespace

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.