how to divide an image into 16x16 non overlapping blocks

10 ビュー (過去 30 日間)
Navya George
Navya George 2017 年 1 月 28 日
コメント済み: Walter Roberson 2022 年 8 月 16 日
how to divide an image into 16x16 non overlapping blocks for finding the local binary pattern in the further steps
  1 件のコメント
Navya George
Navya George 2017 年 1 月 30 日
we are first transforming the input image into YCbCr format and then dividing it into 16*16 blocks.So can we apply the above LBP algorithm to find the LBPcode of each block

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

採用された回答

John Chilleri
John Chilleri 2017 年 1 月 28 日
編集済み: John Chilleri 2017 年 1 月 28 日
Hello,
Assuming your image has size m x n where m and n are multiples of 16:
YourImage = im2double(YourImage);
[m,n] = size(YourImage);
Blocks = cell(m/16,n/16);
counti = 0;
for i = 1:16:m-15
counti = counti + 1;
countj = 0;
for j = 1:16:n-15
countj = countj + 1;
Blocks{counti,countj} = YourImage(i:i+15,j:j+15);
end
end
You can access the blocks by calling Blocks{i,j}.
Hope this helps!
  9 件のコメント
Hadeel
Hadeel 2022 年 8 月 16 日
yes,please i want to display all the blocks of subplot in saperate axies
Walter Roberson
Walter Roberson 2022 年 8 月 16 日
img = imresize(imread('flamingos.jpg'), [256 256]);
[rows, cols, panes] = size(img);
rb = rows/16; cb = cols/16;
tiledlayout(rb, cb, 'tilespacing', 'tight');
blockproc(img, [16 16], @dispblock);
function h = dispblock(block_struct)
nexttile();
image(block_struct.data);
axis off
%block_struct.location, hh
h = [];
end

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2017 年 1 月 28 日
編集済み: Image Analyst 2017 年 1 月 28 日
This is a FAQ. See a couple of different ways to do this in the FAQ document: http://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F
See my attached demo for LBP.

Community Treasure Hunt

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

Start Hunting!

Translated by