DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomImage Class / SubImage Method / SubImage(Point,Size,Single,Int32,ScaleMode) Method

The left top corner point of the sub Image

The total size of the original image to capture

The zooming factor which determines the output size

The frame number to use. This is 1-index, i.e. first frame is 1 not 0

The scaling mode to use

Example

In This Topic
    SubImage(Point,Size,Single,Int32,ScaleMode) Method
    In This Topic
    Creates a copy of part or all of the image with controlled size
    Syntax
    'Declaration
     
    
    Public Overloads Overridable Function SubImage( _
       ByVal Offset As System.Drawing.Point, _
       ByVal Size As System.Drawing.Size, _
       ByVal Magnification As System.Single, _
       ByVal Frame As System.Integer, _
       ByVal Scaling As ScaleMode _
    ) As DicomImage
    public virtual DicomImage SubImage( 
       System.Drawing.Point Offset,
       System.Drawing.Size Size,
       System.float Magnification,
       System.int Frame,
       ScaleMode Scaling
    )

    Parameters

    Offset

    The left top corner point of the sub Image

    Size

    The total size of the original image to capture

    Magnification

    The zooming factor which determines the output size

    Frame

    The frame number to use. This is 1-index, i.e. first frame is 1 not 0

    Scaling

    The scaling mode to use

    Return Value

    Remarks

    Makes a derived image (of same basic DICOM type as the original) scaled and cropped as required. Size refers to the final image size, whether or not it is transformed as below.

    The coordinate system used depends on the value of scaling. If ScaleMode.Image then the original image is used without rotation etc, but if ScaleMode.Output then the image is conceptually flipped, rotated etc. before applying the bounds.

    This overload is now recommended in place of the earlier version without the scaling mode which is retained for backwards compatibility only.

    Example
    DicomImage image = new DicomImage("your_dicom_image.dcm");
                        
    Point offset = new Point(0, 0); // top-left corner
    var width = image.Size.Width;
    var height = image.Size.Height; 
    Size size = new Size(width, height);
                        
    float magnification = 2F;
    int frame = 1;
    ScaleMode mode = ScaleMode.Output;
                        
    var copiedImage = image.SubImage(offset, size, magnification, frame, mode);
        
    // optionally write new image to disk
    copiedImage.Write("copied_image.dcm");
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also