2

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

Max
  • 7,408
  • 2
  • 26
  • 32
Baran Barani
  • 21
  • 1
  • 2
  • but if you divide the big image in smaller block, and then compare the blocks between them, then even if there are identical part of the image they may be not aligned with your sliced-block subdivision. So maybe that the blocks wont match (anyway I'm not an image elaboration expert, so maybe I'm totally wrong...) – Max Jul 12 '12 at 13:29
  • Thank you for your answer, i was thinking about your answer and i think you are right. In some cases when i copy some part of the image and paste it to another part, maybe the first block pasted between two blocks and it is difficult to find similar blocks. Theoretically do you have any suggestion how I can do it ? Search for similar parts in one image. – Baran Barani Jul 13 '12 at 09:21
  • I'm not an expert in image elaboration... if the part of the image you are trying to find is 16x16 pixel, and the image is not too big, you can try to compare it to ANY 16x16 block you can create: block 16x16 starting at x=0 and y=0; block 16x16 starting at x=0 and y=1... but this is a very brute force and inefficient algorithm. You should probably look toward some king of algorithm that can extract meaningful feature from your lock, and that is able to scan an image for part that resemble the same "feature" – Max Jul 13 '12 at 15:03

3 Answers3

1

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

Maurits
  • 2,082
  • 3
  • 28
  • 32
  • @ Maurits, thank you for your answer, i will read about blockproc to find out more how i can do it. Do you have any suggestions about Sliding window? – Baran Barani Jul 13 '12 at 09:23
  • 1
    `im2col(..., 'sliding')` will do the sliding window for you. That is, the `'sliding'` option will generate all of the "intermediate" matrices in the sliding window. Also. `im2col` stores each of the windows (neighborhoods) as a column in the matrix it returns. – solvingPuzzles Nov 13 '12 at 00:52
0

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.

Darcara
  • 1,598
  • 1
  • 13
  • 33
0

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.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87