The IDLffMrSID::GetImageData function method extracts and returns the image data from the MrSID file at the specified level and location.
Result = Obj->[IDLffMrSID::]GetImageData ([, LEVEL = lvl] [, SUB_RECT = rect])
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.
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).
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.
PRO MrSID_GetImageData ; Initialize the MrSID file object. oFile = OBJ_NEW('IDLffMrSID', FILEPATH('test_gs.sid', $ SUBDIRECTORY = ['examples', 'data'])) ; Get the range of levels of resolution contained within the file. oFile->GetProperty, LEVELS = lvls PRINT, lvls ; IDL prints, -9, 4 ; Get the image data at level 0. imgDataA = oFile->GetImageData(LEVEL = 0) HELP, 'image array data at full resolution', imgDataA ;IDL prints, Array[1, 512, 512] indicating a grayscale 512 x 512 array. ; Display the full resolution image. oImgA = OBJ_NEW('IDLgrImage', imgDataA) oModelA = OBJ_NEW('IDLgrModel') oModelA->Add, oImgA XOBJVIEW, oModelA, BACKGROUND = [0,0,0], $ TITLE = 'Full Resolution Image', /BLOCK ; Get the image data of a higher resolution image, imgDataB = oFile->GetImageData(LEVEL = -2) HELP, imgDataB ; IDL returns [1,2048,2048] indicating a grayscale 2048 x 2048 array. ; To save processing time, display only a 1024 x 1024 portion of ; the high resolution, using 512,512 as the origin. 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 ; Clean up object references. OBJ_DESTROY, [oFile, oImgA, oModelA, oImgSelect, oModel] END