Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

MATLAB

$
0
0
Any one can explain what is the algorithm used here...
function seg = imseg(img,Lseg,F)
 

if F
% figure; imshow(img); axis on; title('Preprocessed image')
% figure; imshow(img); axis on; title('segmented image')% open a figure to fill with image segments
end


% segment the image 'imaster'
L = size(img);
max_row = floor(L(1)/Lseg);
max_col = floor(L(2)/Lseg);
seg = cell(max_row,max_col);
% hist_img=cell(max_row,max_col);
r1 = 1; % current row index, initially 1
for row = 1:max_row
    
    c1 = 1; % current col index, initially 1
    for col = 1:max_col
        %disp(['--- row/col ' num2str(row) '/' num2str(col)])

        % find end rows/columns for segment
        r2 = r1+Lseg-1;
        c2 = c1+Lseg-1;

        % store segment in cell array
        seg(row,col) = {img(r1:r2,c1:c2,:)};
        
% hist_img(row,col)=imhist(seg(row,col));
%
        if F
        % plot segment
        subplot(max_row,max_col,(row-1)*max_col+col)
        imshow(cell2mat(seg(row,col)))
        imwrite(cell2mat(seg(row,col)),'sample1.png');
        end
        
        % increment col start index
        c1 = c2 +1;
    end
    

Viewing all articles
Browse latest Browse all 19628