how to divide the image into overlapping blocks?

i need to identify the duplicate regions in an image for that i have to divide the image into overlapping blocks of fixed size lets suppose 16*16 pixels and then dct is performed on each block.
Division of blocks should be performed in such a way that if the block is a square of size b × b then the square is slid by one pixel along the image from the upper left corner right and down to the lower right corner.so please tell me how can i perform such kind of division of an image.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Feb. de 2014
See mat2cell() to divide the array into cells. Start by letting the CurrentImage be the original image. Then repeat
T = CurrentImage;
%throw away partial blocks
T(end-mod(size(T,1),16)+1:end, :) = [];
T(:, end-mod(size(T,2),16)+1:end) = [];
now break out of loop if T is empty
Now you can mat2cell to extract 16 x 16 blocks. Store them. Then,
CurrentImage = CurrentImage(2:end,2:end);
and start loop over again. You would be extracting the blocks one over and one down from the first set of blocks. Next iteration you would be going with one over and one down from that, and so on.

1 comentario

sehreen
sehreen el 13 de Feb. de 2014
Editada: sehreen el 13 de Feb. de 2014
thank u very much for your respose
[row col]=size(img);
for i=1:row-7
for j=1:col-7
BLOCK=img(i:i+7,j:j+7)
end
end
sir i am using the above code to divide the image into overlapping blocks of size 8*8 . Now i need to perform
  1. DCT on each block
  2. Quantize the DCT coefficients of each block and then store each quantized block in a row of a matrix.can you please tell me how could i perform it.

Iniciar sesión para comentar.

Más respuestas (1)

Anand
Anand el 11 de Feb. de 2014

2 votos

You could use the blockproc function. You would need to specify a 'BorderSize' of [1 1] and use a BlockSize of [16 16].

4 comentarios

rahul lamba
rahul lamba el 8 de Mayo de 2016
hi everyone, please can you suggest...how to divide an image into blocks with 50% overlapping
You'd have a 'BorderSize' of half the block size.
B = blockproc(yourImage, [16, 16], fun, 'BorderSize', [8, 8])
TUSHAR MURATKAR
TUSHAR MURATKAR el 18 de Sept. de 2017
@image analyst, i tried in the way you explained but i got empty matrix.

Iniciar sesión para comentar.

Preguntada:

el 11 de Feb. de 2014

Comentada:

el 18 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by