function [d] = get_distortion(original_img, new_img)
% -------------------------------------------------------------------------
% MSc Project - MSc in Communications and Signal Processing
% Department of Electrical and Electronic Engineering
% Imperial College London, 2011
%
% Supervisor  : Dr Pier Luigi Dragotti
% Contributor : Andriy Gelman
% Author      : Jon Onativia Bravo
%
% File        : get_distortion.m
% -------------------------------------------------------------------------
% Computes the distortion of a binary shape image as the number of
% erroneous pixels divided by the total number of pixels belonging to the
% shape.
%
% [d] = get_distortion(original_img, new_img)
%
% INPUT:
%  - original_img : Original binary shape (the total number of pixels will 
%                   be measured from this image).
%  - new_img      : Second binary shape.
%
% OUTPUT:
%  - d            : Distortion.
%


%% Shape pixels
bin_img          = (original_img ~= 0);
tot_shape_pixels = sum(bin_img(:));


%% Erroneous pixels
err_img    = (original_img ~= new_img);
err_pixels = sum(err_img(:));


%% Distortion
d = err_pixels / tot_shape_pixels;

%%
