matlab - moving a mxn window inside image -


i have images of sizes mxn .what want want create window mxn step size of 1/4th of image , move inside image left right , top bottom , calculate pixel density

pixel density in window= number of white pixels/total number of pixels 

and fixed pixel density 0.45 set center pixel of window 1 or 0.

is there predefined functions make use of in matlab.

update

i have done following effort

function result=imagepixeldensity(image,window,thresh)     [widthi,heighti]=size(image);     [widthw,heightw]=size(window);     totaldensity=widthw*heightw;     stepw=widhti/4;     r=1:widthi         c=1:heighti             if(c+stepw<widthi && widhtw+stepw <widthi)                 temp=image(r:heightw,c+stepw:widthw+stepw);                 dens=sum(temp(:))/totaldensity;                 if(dens>=thres)                          % donot know here setting or clearing                                           %pixel in window                 end                   stepw=stepw+widthw;             end         end      end end 

instead of going loops use simple function of blockproc setting proper values of bordersize. example be:

mypxden = @(block_struct) ... sum(block_struct.data(:))/(size(block_struct.data,1)*size(block_struct.data,2)/4); i_proc = blockproc(i,[1,1],mypxden,'bordersize',[round(((size(i,1)/4)-1)/2),round(((size(i,2)/4)-1)/2)],'trimborder',false); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -