Baran Barani
Baran Barani

Reputation: 21

How to divide image into same size blocks?

I have an image and I want to divide it to same size blocks. For example image size is 16. I would like to divide my image they apply function ( such as SVD, DWT, Fourier transform ) on each block to search which blocks are similar to each other. For example I can copy one part of the image and paste it to another part of the image so blocks are similar to each other I want to search for those similar blocks.

I am new in Matlab, I really appreciate if anybody can help me how to divide the image. Thanks

Upvotes: 2

Views: 2873

Answers (3)

Jeru Luke
Jeru Luke

Reputation: 21203

I have a solution written in python that you can convert in a form useful for you.

rsize = 4   #row size of the kernel
csize = 4   #column size of the kernel

for r in range(0,resized.shape[0] - rsize, rsize):
    for c in range(0,resized.shape[1] - csize, csize):
        window = resized[r:r+rsize,c:c+csize]

I have assumed the size of the image to be 17 x 17. Here the last column and the last row of the image can be padded with zeroes for this code to work great.

You can apply this logic to MATLAB.

Upvotes: 0

Darcara
Darcara

Reputation: 1608

I cannot provide a matlab answer, but you could look into Image segmentation (google it for examples). There are many different ways to do this, depending on what kind of segments you want.

You could also look in to the paper Super-Resolution from a Single Image that describes a method to search for reoccurring chunks of an image in itself at various scales. Linked papers also describe how to create an image database from small features in multiple images.

Upvotes: 0

Maurits
Maurits

Reputation: 2114

You can use blockproc or im2col. See the documentation of blockproc for examples.

Upvotes: 1

Related Questions