The IDLffMrSID::GetImageData function method extracts and returns the image data from the MrSID file at the specified level and location.
Syntax
Result = Obj->[IDLffMrSID::]GetImageData ([, LEVEL = lvl] [, SUB_RECT = rect])
Return Value
Returns an n-by-w-by-h array containing the image data where n is 1 for grayscale or 3 for RGB images, w is the width and h is the height.
Note: The returned image is ordered bottom-up, the first pixel returned is located at the bottom-left corner of the image. This differs from how data is stored in the MrSID file where the image is top-down, meaning the pixel at the start of the file is located at the top-left corner of the image.
Arguments
None
Keywords
LEVEL
Set this keyword to an integer that specifies the level at which to read the image.
If this keyword is not set, the maximum level is used which returns the minimum resolution (see the LEVELS keyword to IDLffMrSID::GetProperty).
SUB_RECT
Set this keyword to a four-element vector [x, y, xdim, ydim] specifying the position of the lower left-hand corner and the dimensions of the sub-rectangle of the MrSID image to return. This is useful for displaying portions of a high-resolution image.
If this keyword is not set, the whole image will be returned. This may require significant memory if a high-resolution image level is selected.
If the sub-rectangle is greater than the bounds of the image at the selected level the area outside the image bounds will be set to black.
Note: The elements of SUB_RECT are measured in pixels at the current level. This means the point x = 10, y = 10 at level 1 will be located at x = 20, y = 20 at level 0 and x = 5, y = 5 at level 2.
Examples
PRO MrSID_GetImageData
oFile = OBJ_NEW('IDLffMrSID', FILEPATH('test_gs.sid', $
SUBDIRECTORY = ['examples', 'data']))
oFile->GetProperty, LEVELS = lvls
PRINT, lvls
imgDataA = oFile->GetImageData(LEVEL = 0)
HELP, 'image array data at full resolution', imgDataA
oImgA = OBJ_NEW('IDLgrImage', imgDataA)
oModelA = OBJ_NEW('IDLgrModel')
oModelA->Add, oImgA
XOBJVIEW, oModelA, BACKGROUND = [0,0,0], $
TITLE = 'Full Resolution Image', /BLOCK
imgDataB = oFile->GetImageData(LEVEL = -2)
HELP, imgDataB
imgDataSelect = oFile->GetImageData(LEVEL = -2,$
SUB_RECT = [512, 512, 1024, 1024])
oImgSelect = OBJ_NEW('IDLgrImage', imgDataSelect)
oModel = OBJ_NEW('IDLgrModel')
oModel->Add, oImgSelect
XOBJVIEW, oModel, BACKGROUND = [0,0,0], $
TITLE = 'Detail of High Resolution Image', /BLOCK
OBJ_DESTROY, [oFile, oImgA, oModelA, oImgSelect, oModel]
END
Version History