Code covered by the BSD License  

Highlights from
Study of various Digital Image Processing concepts using MATLAB

image thumbnail

Study of various Digital Image Processing concepts using MATLAB

by

 

Study of various Digital Image Processing concepts using MATLAB. .txt files for C are also included

HistPlottingStatParameters.m
clc;
clear all;
close all;
[path,~]=imgetfile();
info=imfinfo(path);
display(info)
if(info.BitDepth~=8)
error('Please choose a valid 8-bit gray image')
else

I=imread(path);

[rows cols]=size(I);

graylevels=2.^(info.BitDepth);
nk=zeros(graylevels,1); %nk is the histogram array
for a=0:graylevels-1
    nk(a+1)=numel(find(I==a));
end
figure();
subplot(2,1,1);
imshow(I);
titleI=sprintf('Input Image: %s',info.Filename);
title(titleI);
subplot(2,1,2);
bar(nk);
axis([0 numel(nk)+10 0 max(nk)+50])
title('Histogram of Image');

% note that rows.*cols=sum(nk)
% mean variance and std dev are calculated using probabilistic methods
zk=0:1:graylevels-1;
zk=zk';
pzk=nk./sum(nk);
m=sum(zk.*pzk);
pzk=nk./sum(nk);
var=sum(((zk-m).^2).*pzk);
stddev=sqrt(var);
%std_dev=std2(I); using built in function std2
statistical_parameters=struct('Mean',m,'Variance',var,'Standard_Deviation',stddev);
display(statistical_parameters)
end

Contact us