简体   繁体   中英

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM