qtgetblk
Block values in quadtree decomposition
Description
Examples
Get Blocks from Quadtree Decomposition
Create a sample matrix representing a small image.
I = [1 1 1 1 2 3 6 6 1 1 2 1 4 5 6 8 1 1 1 1 10 15 7 7 1 1 1 1 20 25 7 7 20 22 20 22 1 2 3 4 20 22 22 20 5 6 7 8 20 22 20 20 9 10 11 12 22 22 20 20 13 14 15 16];
Perform a quadtree decomposition of the image, specifying a threshold of 5. qtdecomp
splits a block if the maximum value of the block elements minus the minimum value of the block elements is greater than the threshold.
S = qtdecomp(I,5)
S = 8x8 sparse double matrix (13 nonzeros)
(1,1) 4
(5,1) 4
(1,5) 2
(3,5) 1
(4,5) 1
(5,5) 2
(7,5) 2
(3,6) 1
(4,6) 1
(1,7) 2
(3,7) 2
(5,7) 2
(7,7) 2
Get the blocks of size 4-by-4 from the quadtree decomposition. qtgetblk
finds two blocks of this size.
[vals,r,c] = qtgetblk(I,S,4);
Select the second returned block. Display the values and the (row,column) coordinates of the upper left corner of the block.
blknum = 2; blockValues = vals(:,:,blknum)
blockValues = 4×4
20 22 20 22
20 22 22 20
20 22 20 20
22 22 20 20
blockCoordinates = ['(',num2str(r(blknum)),',',num2str(c(blknum)),')']
blockCoordinates = '(5,1)'
Input Arguments
I
— Grayscale image
numeric matrix
Grayscale image, specified as a numeric matrix.
Data Types: single
| double
| int16
| uint8
| uint16
| logical
S
— Quadtree structure
sparse matrix
Quadtree structure, specified as a sparse matrix. If
S
(m,n) is nonzero, then the
coordinate (m,n) is the upper left corner of a block in
the decomposition, and the size of the block is given by
S
(m,n). You can get a quadtree
structure by using the qtdecomp
function.
Data Types: double
dim
— Block size
positive integer
Block size, specified as a positive integer.
Output Arguments
vals
— Block values
dim
-by-dim
-by-k array | []
Block values, returned as a
dim
-by-dim
-by-k array, where
k is the number of dim
-by-dim
blocks
in the quadtree decomposition. If the quadtree decomposition contains no blocks of the
specified size, then vals
is returned as an empty matrix.
The ordering of the blocks in vals
matches the column-wise order of
the blocks in I
. For example, if vals
is 4-by-4-by-2,
then vals(:,:,1)
contains the values from the first 4-by-4 block in
I
, and vals(:,:,2)
contains the values from the second
4-by-4 block.
r
— Row coordinates of upper left corners of blocks
k-element column vector | []
Row coordinates of the upper left corners of blocks, returned as a
k-element column vector of positive integers, where k is
the number of dim
-by-dim
blocks in the quadtree
decomposition. If the quadtree decomposition contains no blocks of the specified size, then
r
is returned as an empty matrix.
c
— Column coordinates of upper left corners of blocks
k-element column vector | []
Column coordinates of the upper left corners of blocks, returned as a
k-element column vector of positive integers, where k
is the number of dim
-by-dim
blocks in the quadtree
decomposition. If the quadtree decomposition contains no blocks of the specified size, then
c
is returned as an empty matrix.
idx
— Linear indices of upper left corners of blocks
k-element column vector | []
Linear indices of upper left corners of blocks, returned as a
k-element column vector of positive integers, where k is
the number of dim
-by-dim
blocks in the quadtree
decomposition. If the quadtree decomposition contains no blocks of the specified size, then
idx
is returned as an empty matrix.
Version History
Introduced before R2006a
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)