Main Content

getRegion

Read arbitrary region of blocked image

    Description

    example

    pixels = getRegion(bim,pixelStart,pixelEnd) returns all the pixels in the blocked image bim, in the region specified by pixelStart and pixelEnd.

    pixels = getRegion(bim,pixelStart,pixelEnd,'Level',L) gets the specified region from the L'th level of the multiresolution blockedImage, bim. pixelStart and pixelEnd are pixel subscripts at the L'th level. By default, L is 1.

    Examples

    collapse all

    Create a blocked image.

    bim = blockedImage('tumor_091R.tif');

    Specify a region in the blocked image and retrieve the data.

    pstart_l1 = [2100, 1800, 1];
    pend_l1 = [2600, 2300, 3];
    imL1 = getRegion(bim, pstart_l1, pend_l1, "Level", 1);

    Convert the start and end points of the region to world coordinates.

    wstart_l1 = sub2world(bim, pstart_l1, "Level", 1);
    wend_l1 = sub2world(bim, pend_l1, "Level", 1);

    Convert the world coordinates to level 3 pixel subscripts.

    pstart_l3 = world2sub(bim, wstart_l1, "level", 3);
    pend_l3 = world2sub(bim, wend_l1, "level", 3);
    imL3 = getRegion(bim, pstart_l3, pend_l3, "Level", 3);

    Display the region in both resolution levels.

    montage({imL1, imL3});

    Figure contains an axes. The axes contains an object of type image.

    Input Arguments

    collapse all

    Blocked image, specified as a blockedImage object.

    Top-left coordinates of the rectangular region, specified as a 1-by-2 numeric vector of the form [x y]. Specify the pixel locations in world coordinates, relative to the highest resolution level.

    Bottom-right coordinates of the rectangular region, specified as a 1-by-2 numeric vector of the form [x y]. Specify the pixel locations in world coordinates, relative to the highest resolution level.

    Output Arguments

    collapse all

    Pixels in specified region, returned as a numeric array.

    Introduced in R2021a