imcrop3
Crop 3-D image
Syntax
Description
Examples
Crop 3-D Volume
Load a 3-D volume into the workspace.
load("mristack")
Display the image.
volshow(mristack);
Specify the size and position of the cuboidal crop region. Then, crop the volume using imcrop3
.
cropRegion = [30 40 10 100 100 10]; Vcropped = imcrop3(mristack,cropRegion);
Display the cropped image.
volshow(Vcropped);
Crop 3-D Image Volume Using Fixed Off-Center Spatial Extent
Load a 3-D MRI image. Use the squeeze
function to remove any singleton dimensions.
load('mri.mat','D'); volumeData = squeeze(D);
Display the image.
volshow(volumeData);
Create a Cuboid
object and specify the cropping window size in all three dimensions.
c = images.spatialref.Cuboid([30,90],[30,90],[1,20]);
Crop the image based on the Cuboid
dimensions.
croppedVolume = imcrop3(volumeData,c);
Display the cropped image.
volshow(croppedVolume);
Center Crop 3-D Image to Target Size
Load a 3-D MRI image. Use the squeeze
function to remove any singleton dimensions.
load mri;
D = squeeze(D);
Display the image.
volshow(D);
Specify the target size of the cropping window.
targetSize = [64 64 10];
Create a center cropping window that crops an image from its center.
win = centerCropWindow3d(size(D),targetSize);
Crop the image using the center cropping window.
Dcrop = imcrop3(D,win);
Display the cropped image.
volshow(Dcrop);
Input Arguments
V
— Volume to be cropped
numeric array | logical array | categorical array
Volume to be cropped, specified as a numeric, logical, or categorical array.
V
can be a 3-D array that represents a single channel 3-D volume
or a 4-D array that represents a multichannel 3-D volume. If V
represents a multichannel 3-D volume, then imcrop3
crops the first
three dimensions only.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| categorical
cuboid
— Size and position of crop volume
6-element numeric vector | Cuboid
object
Size and position of the crop volume in spatial coordinates, specified as a
6-element vector of the form [xmin ymin zmin width height depth]
or a
images.spatialref.Cuboid
object.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
Vout
— Cropped volume
logical, numeric, or categorical array
Cropped volume, returned as a logical, numeric, or categorical array of the same
class as the input volume V
.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2019bR2021b: Support for thread-based environments
imcrop3
now supports thread-based
environments.
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)