<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">

Exported from Notepad++
clc; clear all; close all; im=imread('cameraman.tif'); [m n]=size(im); pixels=[]; levels=256; for k=0:levels-1 count=0; for i=1:m for j=1:n if im(i,j)==k count=count+1; end pixel(k+1)=count; end end end figure,stem((0:255),pixel); figure,bar((0:255),(pixel./(m*n))); figure,imhist(im);