Sei sulla pagina 1di 3

2/1/2018 image processing - Is there a substitute for blockproc in Matlab?

- Stack Overflow

Is there a substitute for blockproc in Matlab?

I've been using blockproc for processing images blockwise. Unfortunately, blockproc is part of the Image Processing Toolbox, which I don't
have on my personal computer.

Is there a combination of functions in base Matlab that can substitute for blockproc ?

My initial guess was to use im2col to transform each block into columns, and then arrayfun to process each column. Then I realized that
im2col is also a part of the Image Processing Toolbox, so that doesn't solve my problem.

matlab image-processing matrix

edited Jun 29 '12 at 15:12 asked Jun 28 '12 at 3:37


Amro SetchSen
111k 19 194 358 28 1 6

migrated from dsp.stackexchange.com Jun 28 '12 at 5:59


This question came from our site for practitioners of the art and science of signal, image and video processing.

related question: Matlab - merge submatrices – Amro Jun 29 '12 at 15:11

2 Answers

Here is an example using MAT2CELL. It dividing the image into N-by-M tiles, and handles the
case when the image size is not evenly divisible by the number of tiles.

%# 2D grayscale image
I = imread('coins.png');

%# desird number of horizontal/vertical tiles to divide the image into


numBlkH = 4;
numBlkW = 4;

%# compute size of each tile in pixels


[imgH,imgW,~] = size(I);
szBlkH = [repmat(fix(imgH/numBlkH),1,numBlkH-1) imgH-fix(imgH/numBlkH)*(numBlkH-1)];
szBlkW = [repmat(fix(imgW/numBlkW),1,numBlkW-1) imgW-fix(imgW/numBlkW)*(numBlkW-1)];

%# divide into tiles, and linearize using a row-major order


C = mat2cell(I, szBlkH, szBlkW)';
C = C(:);

%# display tiles i subplots


figure, imshow(I)
figure
for i=1:numBlkH*numBlkW
subplot(numBlkH,numBlkW,i), imshow( C{i} )
end

The input image and the resulting tiles:

https://stackoverflow.com/questions/11238828/is-there-a-substitute-for-blockproc-in-matlab?noredirect=1&lq=1 1/3
2/1/2018 image processing - Is there a substitute for blockproc in Matlab? - Stack Overflow

Join Stack Overflow to learn, share knowledge, and build your career. Email Sign Up OR SIGN IN WITH Google Facebook

answered Jun 29 '12 at 15:20


Amro
111k 19 194 358

Won't mat2tiles together with cellfun and cell2mat do more or less what blockproc does?

You could write a wrapper yourself to make it use the same arguments as blockproc , I don't
think it should be that hard to do.

answered Jun 28 '12 at 8:52


Egon
4,349 15 34

https://stackoverflow.com/questions/11238828/is-there-a-substitute-for-blockproc-in-matlab?noredirect=1&lq=1 2/3
2/1/2018 image processing - Is there a substitute for blockproc in Matlab? - Stack Overflow

https://stackoverflow.com/questions/11238828/is-there-a-substitute-for-blockproc-in-matlab?noredirect=1&lq=1 3/3

Potrebbero piacerti anche