Pack binary image
Pack, Dilate, and Unpack Binary Image
Read binary image into the workspace.
BW = imread('text.png');
Pack the image.
BWp = bwpack(BW);
Dilate the packed image.
BWp_dilated = imdilate(BWp,ones(3,3),'ispacked');
Unpack the dilated image and display it.
BW_dilated = bwunpack(BWp_dilated, size(BW,1)); imshow(BW_dilated)
BW — Binary image
2-D numeric matrix | 2-D logical matrix
Binary image, specified as a 2-D numeric or logical matrix.
BWP — Packed binary image
Packed binary image, returned as a numeric matrix of data type
bwpack processes the input image pixels by column, mapping groups of
32 pixels into the bits of a
uint32 value. The first pixel in the first row
corresponds to the least significant bit of the first
uint32 element of the
output array. The first pixel in the 32nd input row corresponds to the most significant bit of
this same element. The first pixel of the 33rd row corresponds to the least significant bit of
the second output element, and so on. If
N. This figure illustrates how
bwpack maps the pixels in a binary image to the bits in a packed binary
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
bwpacksupports the generation of C code (requires MATLAB® Coder™). The code generated for
bwpackuses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Types of Code Generation Support in Image Processing Toolbox.
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version HistoryIntroduced before R2006a
R2022b: Support for thread-based environments
bwpack now supports thread-based