MATLAB: Image dividing, padding, regions

image divide

How to divide an image up into say 10×10 regions and account for padding (an integer number of regions does not fit in the image)
I have tried complicated convolution methods, and now want to try a more simplified approach. The aim is to then locally threshold each image for SNR calculations
This was my attempt:
n=10; %regions in each dimension
[x,y]=size(ROI)
nx=floor(x/n)
ny=floor(y/n)
xGrid=1:(nx+1):10*nx
yGrid=1:(ny+1):10*ny
[X,Y]=meshgrid(xGrid,yGrid)
mesh(X,Y)

Best Answer

Attached is a demo where I use local thresholding to correct a shaded document to prepare it for OCR.