如何将图像matlab划分为重叠块
问题描述:
我需要使用matlab将512 * 512的图像分成41 * 41重叠的部分,换句话说,我想先获取一个以q为中心的41 * 41块,然后再移动一个像素,然后获取一个41 * 41以q + 1居中,依此类推..我不能使用Blockproc,因为它提供了一个不重叠的块.
I need to divide an image 512*512 into 41*41 overlapping using matlab.In other words, I want to take first a 41*41 block centred in q then I shift by a pixel and I take a 41*41 centered in q+1 and so on.. I can't use Blockproc because it gives a not overlapping block.
感谢帮助我
答
您可以使用BLOCKPROC.这不太明显.
You CAN use BLOCKPROC. It is a bit non-obvious.
将块大小设置为[1 1],然后使用'Border'参数指定每个像素周围所需的块大小:
Set a block size of [1 1], and then use the 'Border' parameter to specify how big a block you want around each pixel:
>> a
a =
8 1 6
3 5 7
4 9 2
>> blockproc(a, [1 1], @(bs)disp(bs.data),'BorderSize', [1 1 ])
0 0 0
0 8 1
0 3 5
0 0 0
1 6 0
5 7 0
0 3 5
0 4 9
0 0 0
5 7 0
9 2 0
0 0 0
0 0 0
8 1 6
3 5 7
0 8 1
0 3 5
0 4 9
8 1 6
3 5 7
4 9 2
3 5 7
4 9 2
0 0 0
1 6 0
5 7 0
9 2 0