Hi guys,
I am trying to write a code to correct the background for an image. I used the formula given in the paper "Methods of Digital Video Microscopy for Colloidal Studies" by Crocker and Grier.
The formula is
Ib(x,y)=(constant)*[?I(x+i,y+j)] %the summation goes from i,j= -w to +w; w is predefined. 'I' is the original image and 'Ib' the background corrected image.
I thought of using "cumsum" since we need to sum up the components of the rows and columns of a matrix basically to decrease the computation time. However I am getting an error and I am clueless about what I am doing wrong.
The code is given below
I=imread('*.tif');I=rgb2gray(I);sizeim=size(I); %computes size of image
Iback=zeros(sizeim(1),sizeim(2)); %Iback same size as I but with zeros
B=1/((2*w+1)^2); %constant used for division
w=5;for i=w+1:sizeim(1)-w for j=w+1:sizeim(2)-w temp=cumsum(cumsum(I(i-w:i+w,j-w:j+w),1),2); Iback(i,j)=temp(2*w+1,2*w+1)/B; end end
I get the error message "??? Undefined function or method 'cumsum' for input arguments of type 'uint8'"
Can anyone tell me what I am doing wrong? Your help is truly appreciated.
NS
Best Answer