l'image de fond

fr       en

Traitements d'Images Binaire

Projection

Définition

La projection d'une image consiste à compter le nombre de pixels d'une image qui sont à 1 (ou à 0) sur chaque ligne pour une projection horizontale ou sur chaque colonne pour une projection verticale.

Programme

clear all;
close all;

[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...
          '*.*','All Files' },'mytitle',...
          'C:\Work\myfile.jpg')

img = imread(filename);
img = img(:,:,1);
img(img<128)=0;
img(img>=128)=1;
img=~img;

[ligne colonne]=size(img)

projection_H=zeros(ligne,1);
img_H=zeros(ligne,colonne);
projection_V=zeros(1,colonne);
img_V=zeros(ligne,colonne);

for i = 1 : ligne
    projection_H(i,1) = sum(img(i,:));
    if projection_H(i,1)~= 0
        img_H(i,1:projection_H(i,1))=1;
    end
end
for i = 1 : colonne
    projection_V(1,i) = sum(img(:,i));
    if projection_V(1,i)~= 0
        img_V(1:projection_V(1,i),i)=1;
    end
end

figure(  'Name','translation',...
            'NumberTitle','off',...
            'color',[0.3137 0.3137 0.5098]);
subplot(221)
imshow(img)
title('Image')
subplot(222)
imshow(img_H)
title('Projection Horizontale')
subplot(223)
imshow(img_V)
title('Projection Verticale')
 

Exemple


projection

Copyright © 2010-2014, tous droits réservés, contact : operationpixel@free.fr