# Binary Processing

## Projections

### Definition

Projections of an image is to count the number of pixel of an image wich are to 1 (or to 0) on each ligne for an horizontal projection or on each column for a vertical projection.

### Program

```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')  ```