makeMultiLevel2D
R2026bDescription
specifies additional options, such as the scale factors and interpolation method, using
name-value arguments. For example, specify mbim = makeMultiLevel2D(bim,Name=Value)Interpolation="cubic" to use
bicubic interpolation when resizing each level of the image.
Examples
Create a blocked image from a large image. The file tumor_110.tif contains a single-resolution 2-D image that exceeds 2048-by-2048 pixels.
bim = blockedImage("tumor_110.tif");
bim.Sizeans = 1×3
2560 3072 3
Make a multilevel blocked image.
multibim = makeMultiLevel2D(bim);
Display the size of the multilevel blocked image. The second level is half the size of the original image.
multibim.Size
ans = 2×3
2560 3072 3
1280 1536 3
Input Arguments
Blocked image, specified as a blockedImage
object containing 2-D image data. If the blocked image has multiple resolution levels,
then makeMultiLevel2D uses the image at the finest resolution
level.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: mbim = makeMultiLevel2D(bim,Interpolation="cubic") uses
bicubic interpolation when resizing each level.
Scale factors, specified as a vector of positive numbers. If you want the new
multilevel blocked image to include the original blocked image, then include
1 as an element of Scales.
If you use a TIFF Adapter, then the scaled block sizes must
be multiples of 16 pixels. If you specify scale factors that result in invalid block
sizes, then the makeMultiLevel2D function rounds the scaled block
sizes to the nearest multiple of 16 pixels.
Example: [1 0.66 0.5 0.33] creates a 4-level blocked image with
levels that are 1, 0.66, 0.5, and 0.33 times the size of the initial
image.
Example: [0.5 0.1] creates a 2-level blocked image with levels
that are 0.5 and 0.1 times the size of the original image.
Block size of data, specified as a 2-element vector of positive integers. The
default value for the TIFF
adapter is equal to the block size of bim at the finest
resolution level, rounded to the nearest multiple of 256. The default value for most
other adapters is equal to the block size of bim at the finest
resolution level.
Interpolation method, specified as one of these values.
| Interpolation Method | Description |
|---|---|
"nearest" | Nearest-neighbor interpolation. The output pixel is assigned the value of the pixel that the point falls within. No other pixels are considered. Nearest-neighbor interpolation is the only method supported for categorical images and it is the default method for images of this type. |
"linear" | Linear interpolation. Linear interpolation is the default interpolation method for numeric and logical images. |
"cubic" | Cubic interpolation. |
When the method is "linear" or "cubic", the
function also performs antialiasing.
Location of the output folder, specified as a string scalar or character vector.
When the UseParallel argument is "on" or
"auto", specify OutputLocation as a valid
path on the client session. Use the AlternateFileSystemRoots
property of the input blocked image bim to specify the required
mapping for worker sessions.
Adapter used for writing blocked image data, specified as an adapter object with write capabilities. This table lists the supported adapters included with the toolbox.
| Adapter | Description |
|---|---|
BINBlocks | Store each block as a binary file in a folder |
GenericImage
| Store blocks in a single image |
GenericImageBlocks | Store each block as an image file in a folder |
H5 | Store blocks in a single HDF5 image |
H5Blocks | Store each block as an HDF5 file in a folder |
InMemory | Store blocks in a variable in main memory |
JPEGBlocks | Store each block as a JPEG file in a folder |
MATBlocks | Store each block as a MAT file in a folder |
PNGBlocks | Store each block as a PNG file in a folder |
TIFF | Store blocks in a single TIFF file |
You can also specify a custom adapter that performs custom writing operations. For
more information, see images.blocked.Adapter.
If the source of bim is in memory, and you do not specify the
OutputLocation argument, then the default adapter is an InMemory
adapter. Otherwise, the default value is a TIFF
adapter.
Option to perform computations in parallel using a parallel pool of workers, specified as one of these values:
"off"— Run in serial on the MATLAB® client."auto"— Use a parallel pool if one is open or if MATLAB can automatically create one. If a parallel pool is not available, then run in serial on the MATLAB client."on"— Use a parallel pool if one is open or if MATLAB can automatically create one. If a parallel pool is not available, then throw an error.
Before R2026b: To run in parallel, set
UseParallel to true
(1).
If you do not have a parallel pool open and automatic pool creation is enabled, then MATLAB opens a pool using the default cluster profile. To use a parallel pool to run computations in MATLAB, you must have Parallel Computing Toolbox™. For more information, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
The adapter specified by the Adapter argument must support
parallel processing. You must specify OutputLocation as a valid
path on the client session.
Data Types: char | string
Display wait bar, specified as a numeric or
logical 1 (true) or 0
(false). When set to true, the
makeMultiLevel2D function displays a wait bar for long-running
operations. If you cancel the wait bar, the makeMultiLevel2D
function returns partial output, if available.
Data Types: logical
Output Arguments
Multilevel blocked image, returned as a blockedImage
object. The function orders the levels from finest to coarsest resolution.
Tips
If you want to create overview levels for a very large blocked image, consider creating the overview levels in memory, and then combining the original image and the overview levels using the
concatenateLevelsfunction. This approach does not require creating a second copy of the original image.
Extended Capabilities
The makeMultiLevel2D function has automatic parallel
support.
To run computations in parallel, set the UseParallel argument to
"on" or "auto". The adapter specified by the
Adapter argument must support parallel processing. You must specify a
valid OutputLocation.
For more information, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
Version History
Introduced in R2023aThe UseParallel name-value argument now accepts
"off", "auto", or "on" values
instead of true (1) or false
(0). This change gives you more control over when to use a parallel
pool for parallel execution.
Specifying the UseParallel name-value argument as
true or false is not recommended. This table shows
how to update your code depending on your goal.
| Goal | Not recommended | Recommended |
|---|---|---|
Write code that runs on the MATLAB client. | makeMultiLevel2D(bim, UseParallel=false) | makeMultiLevel2D(bim, UseParallel="off") |
Write portable code that runs on a parallel pool and, if a pool is not available, runs on the MATLAB client. | makeMultiLevel2D(bim, UseParallel=true) | makeMultiLevel2D(bim, UseParallel="auto") |
Write code that runs on a parallel pool and errors if a pool is not available. | N/A | makeMultiLevel2D(bim, UseParallel="on") |
There are no plans to remove support for the true or
false values.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)