Tuesday, 17 January 2017

program to divide an image into blocks and count the 1's or edge information in the first row all blocks.

clear all;
close all;
I=imread('image_0001.png');
imNo=1;
grayI=rgb2gray(I);
[rows cols]=size(grayI);
edges=edge(grayI,'sobel');
sRow=floor(rows/6);
sCols=floor(cols/8);

for blockCount=1:8 % runs for each column
block=blockCount;
in(imNo,block)=0;
for j= 1:(2*sRow)  % inside the block to iterate through the  rows in the block
for k=(blockCount-1)*sCols+1: blockCount*sCols      % to iterate through columns
in(imNo,block)=in(imNo,block)+edges(j,k); % since edges contain 0's and 1's , only 1's will be added and so this will return the number of one's in each block
end
end
end

No comments:

Post a Comment