how to divide an image into 16x16 non overlapping blocks

how to divide an image into 16x16 non overlapping blocks for finding the local binary pattern in the further steps

댓글 수: 1

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

Jan
Jan 2017년 1월 29일
편집: Jan 2017년 1월 29일
+1: This even works, when m and n are not multiple of 16, when you use:
Blocks = cell(ceil(m/16), ceil(n/16));
But, unlike the FAQ, it will not get the "remainder" parts that are beyond the multiple of 16. The FAQ does because it computes the sizes in advance before using cell2mat(). However, those remainder parts won't be really needed in the LBP code.
And doesn't give local binary pattern code, though computing a local binary pattern for a square ring would take 16+16+14+14 = 60 bits. A 60 bit can be contained in a uint64 variable, which MATLAB has. Not sure if this would show anything better than the usual 3x3 box but it might. It would be an interesting test that you could do by changing the width parameter in my code.
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
I need to divide my binary digit image into 3*2 blocks. Is the following code gonna help me? Suppose, the size of the binary digit image is 64*64
% code
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
How do you display the image with the blocks.
yes iam also need it
@Hadeel, not sure what you mean. THe image with the blocks is the original image. Any of the "block" images are an image of a single block cropped out of the original, larger image. Which image(s) do you want to display: the original or one of the blocks? Or do you want to display all of the blocks in subplots so that they're physically separated in different axes?
yes,please i want to display all the blocks of subplot in saperate axies
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일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Vehicle Network Toolbox에 대해 자세히 알아보기

질문:

2017년 1월 28일

댓글:

2022년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by