The SaveImage Method is available in LEADTOOLS Document and Medical Imaging toolkits.
- image
- MRC image to save.
- fileName
- The output file name.
- format
- The output file format.
- options
- Structure that contains the compression information to use when saving the file.
- codecs
- extended saving options support
Visual Basic (Declaration) | |
---|---|
Public Sub SaveImage( _ ByVal image As RasterImage, _ ByVal fileName As String, _ ByVal format As MrcImageFormat, _ ByVal options As MrcCompressionOptions, _ ByVal codecs As RasterCodecs _ ) |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As MrcSegmenter Dim image As RasterImage Dim fileName As String Dim format As MrcImageFormat Dim options As MrcCompressionOptions Dim codecs As RasterCodecs instance.SaveImage(image, fileName, format, options, codecs) |
C# | |
---|---|
public void SaveImage( RasterImage image, string fileName, MrcImageFormat format, MrcCompressionOptions options, RasterCodecs codecs ) |
C++/CLI | |
---|---|
public: void SaveImage( RasterImage^ image, String^ fileName, MrcImageFormat format, MrcCompressionOptions options, RasterCodecs^ codecs ) |
Parameters
- image
- MRC image to save.
- fileName
- The output file name.
- format
- The output file format.
- options
- Structure that contains the compression information to use when saving the file.
- codecs
- extended saving options support
Visual Basic | Copy Code |
---|---|
Public Sub SaveImageExample() ' Load an image Dim codecs As RasterCodecs = New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.mrc")) Dim segmenter As MrcSegmenter = New MrcSegmenter(image, Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.sgm")) Dim compressionOptions As MrcCompressionOptions = MrcCompressionOptions.Empty compressionOptions.MaskCoder = MrcMaskCompression.FaxG31D compressionOptions.PictureCoder = MrcPictureCompression.Jpeg compressionOptions.PictureQualityFactor = 10 compressionOptions.Grayscale8BitCoder = MrcGrayscaleCompression8BitCoder.GrayscaleCmw compressionOptions.Grayscale8BitFactor = 2 compressionOptions.Grayscale2BitCoder = MrcGrayscaleCompression2BitCoder.Jbig2 compressionOptions.Text2BitCoder = MrcTextCompression2BitCoder.Jbig2Bit Try segmenter.SaveImage(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.Mrc"), MrcImageFormat.Mrc, compressionOptions, codecs) Catch e As Exception MessageBox.Show(e.Message) End Try End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void SaveImageExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir,"MRCSegmentation.mrc")); MrcSegmenter segmenter = new MrcSegmenter(image,Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.sgm")); MrcCompressionOptions compressionOptions = MrcCompressionOptions.Empty; compressionOptions.MaskCoder = MrcMaskCompression.FaxG31D; compressionOptions.PictureCoder = MrcPictureCompression.Jpeg; compressionOptions.PictureQualityFactor = 10; compressionOptions.Grayscale8BitCoder = MrcGrayscaleCompression8BitCoder.GrayscaleCmw ; compressionOptions.Grayscale8BitFactor = 2; compressionOptions.Grayscale2BitCoder = MrcGrayscaleCompression2BitCoder.Jbig2; compressionOptions.Text2BitCoder = MrcTextCompression2BitCoder.Jbig2Bit; try { segmenter.SaveImage(image,Path.Combine(LEAD_VARS.ImagesDir,"Out_Result.Mrc"), MrcImageFormat.Mrc, compressionOptions, codecs); } catch(Exception e) { MessageBox.Show(e.Message); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
Use this method to save the image in one of the LEAD Proprietary MRC formats either as a :
When the format parameter is set to MrcImageFormat.MrcTif, *.TIF is the default file extension.
When the format parameter is set to MrcImageFormat.MrcPdf, *.PDF is the default file extension.
Use this method to save a file in one of the LEAD proprietary MRC formats or PDF file based on LEAD segmentation technique if you want to:
Use the MrcSegmenter.SaveImageT44 method to save a file if it is necessary that the file be readable by any application that supports the T44 standard.
It is best to perform segmentation before calling this method. Segmentation can be performed automatically by calling the MrcSegmenter.SegmentImage method, or performed manually by calling the MrcSegmenter.AddSegment method.
When using this method, segmentation can be done using any one of the flags from the MrcSegmentType enumeration.
The MrcSegmenter.SegmentImage method maps the text, grayscale and picture segments into layers (mask, background and foreground layers) as defined in the NLS* model of the T.44 standard. A segment is a rectangular area on the image that can be classified as text, grayscale, or picture, depending on the number of colors used in its area. The Mixed Raster Content (MRC) format was developed by the International Telecommunications Union as part of ITU-T Recommendation T.44. For more information on Mixed Raster Content (MRC) formats, refer to General Segmentation Information. If the options parameter is empty, then the function will use Fax G4 compression for the mask layer, JPEG compression for the 24 bit image segments and 2 for the quality factor, JPEG compression for the 8 bit grayscale segments and 2 for the quality factor, and JBIG compression for the 2 bit text and 2 bit grayscale segments. For more information, refer to Leadtools.Mrc.MrcCompressionOptions. Note that the Grayscale2BitCoder , the Grayscale8BitCoder , the Grayscale8BitFactor, and the Text2BitCoder properties of the Leadtools.Mrc.MrcCompressionOptions. structure is used with the MrcImageFormat.Mrc and MrcImageFormat.MrcPdf formats only. *NLS (N-Layer stripe) means that each stripe may contain one or more mask layers, foreground layers, and background layers.
- LEAD proprietary MRC format file (if the format parameter is set to MrcImageFormat.Mrc)
- TIF file with a LEAD MRC subtype format (if the format parameter is set to MrcImageFormat.MrcTif
- Multiple document PDF using segmentation capabilities (if the format parameter is set to MrcImageFormat.MrcPdf).
When the format parameter is set to MrcImageFormat.MrcTif, *.TIF is the default file extension.
When the format parameter is set to MrcImageFormat.MrcPdf, *.PDF is the default file extension.
Use this method to save a file in one of the LEAD proprietary MRC formats or PDF file based on LEAD segmentation technique if you want to:
- Take advantage of the greater number of different segment types available when using the proprietary format.
- Create smaller files than would be possible by saving them to the Standard T44 format.
- Create higher quality files than would be possible by saving them to the Standard T44 format.
Use the MrcSegmenter.SaveImageT44 method to save a file if it is necessary that the file be readable by any application that supports the T44 standard.
It is best to perform segmentation before calling this method. Segmentation can be performed automatically by calling the MrcSegmenter.SegmentImage method, or performed manually by calling the MrcSegmenter.AddSegment method.
When using this method, segmentation can be done using any one of the flags from the MrcSegmentType enumeration.
The MrcSegmenter.SegmentImage method maps the text, grayscale and picture segments into layers (mask, background and foreground layers) as defined in the NLS* model of the T.44 standard. A segment is a rectangular area on the image that can be classified as text, grayscale, or picture, depending on the number of colors used in its area. The Mixed Raster Content (MRC) format was developed by the International Telecommunications Union as part of ITU-T Recommendation T.44. For more information on Mixed Raster Content (MRC) formats, refer to General Segmentation Information. If the options parameter is empty, then the function will use Fax G4 compression for the mask layer, JPEG compression for the 24 bit image segments and 2 for the quality factor, JPEG compression for the 8 bit grayscale segments and 2 for the quality factor, and JBIG compression for the 2 bit text and 2 bit grayscale segments. For more information, refer to Leadtools.Mrc.MrcCompressionOptions. Note that the Grayscale2BitCoder , the Grayscale8BitCoder , the Grayscale8BitFactor, and the Text2BitCoder properties of the Leadtools.Mrc.MrcCompressionOptions. structure is used with the MrcImageFormat.Mrc and MrcImageFormat.MrcPdf formats only. *NLS (N-Layer stripe) means that each stripe may contain one or more mask layers, foreground layers, and background layers.
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
Reference
MrcSegmenter ClassMrcSegmenter Members
SegmentImage Method
SaveImageT44 Method
LoadImage Method
GetPagesCount Method
Save Method
SaveBitmapList Method
Programming with LEADTOOLS MRC