get distnct blocks contained in a given matrix.

1 回表示 (過去 30 日間)
MatlabEnthusiast
MatlabEnthusiast 2021 年 11 月 23 日
コメント済み: MatlabEnthusiast 2021 年 11 月 24 日
Hello. Lets say an image of size [M N] to blocks of size [i j] each. using the following piece of code:
A = im2col(im,[i j],'distinct');
% ....
% ....
% ....
% do some more operations on A
% derive submatrix B of size [m n] from A.
% QUESTION
% How can I retrieve the distnct blocks of size (i, j) contained in B
% and store them say in a different matrix.
% Thank you very much.
After a series of more operations, I derive a submatrix, say B of size [m n] from A.
My question is. How can I find how many blocks of size (i, j) are in B. Also how can I store these blocks in a different array? Thank you very much.

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 23 日
In any one direction, if you need distinct blocks of size P and the available length along the dimension is Q, then the number of ways you can position the block along that dimension is (Q-P+1) . For example blocks of length 3 in a vector of length 5, [a b c d e f] can be [a b c], [b c d], [d e f] -- three different blocks, and (5-3+1) = 3 .
Now you have the same calculation along the other dimension.
Finally, you multiply the values for all of the dimensions.
  9 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 24 日
When you pass an array into num2cell, and you pass in the optional argument 1 then the output will be a cell array in which each column of the original matrix is an individual cell array entry.
MatlabEnthusiast
MatlabEnthusiast 2021 年 11 月 24 日
alright Walter. Finally, So how is this for a crude extraction of block starting at (1,1). If its right, how best can I generalize this to get say, the block at (r, c)?
b1_crude=[separated{1}(1:8) separated{2}(1:8) separated{3}(1:8) separated{4}(1:8) separated{5}(1:8) separated{6}(1:8) separated{7}(1:8) separated{8}(1:8)];

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by