# hw1dip - end end%Quantized to 64 levels y = zeros(size(x...

This preview shows pages 1–4. Sign up to view the full content.

Katherine Haas – UNI: kah2190 Digital Image Processing Homework #1 1. L=8, MSE=92.5370 L=16, MSE= 23.0245 L=32, MSE= 5.7109 L=64, MSE=1.5493 Matlab code for following: function [y, MSE]=quantize(L); x = imread( 'bird.bmp' ); [height, width] = size(x); B = 256; x = double(x);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
%Build the quantization table Q = zeros(256,1); q = B/L; for i = 0:255, Q(i+1,1)=floor(i/q)*q +q/2; end %Quantized to 64 levels y = zeros(size(x)); for i=1:height, for j=1:width, y(i,j)=Q(x(i,j)+ 1); end end MSE=mean(mean((x-y).^2)); y = uint8(y); 2. L=8, MSE=674.5573 L=16, MSE= 168.0335 L=32, MSE= 43.2159 L=64, MSE= 11.6863 Matlab code: function [y, MSE]=noise(L); x = imread( 'bird.bmp' ); [height, width] = size(x); B = 256; x = double(x); %Build the quantization table Q = zeros(256,1);
q = B/L; for i = 0:255, Q(i+1,1)=floor(i/q)*q +q/2; end %Generate random noise noise = rand(height,width); for i=1:height, for j=1:width, noise(i,j)= (floor(noise(i,j)-.5).*q);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end end %Quantized to 64 levels y = zeros(size(x)); for i=1:height, for j=1:width, y(i,j)=Q(x(i,j)+ 1); end end x=x+noise; MSE=mean(mean((x-y).^2)); y= y-noise; y = uint8(y); To get similar image quality, the noise method needs a lower L. 3. Used matlab to compute the MSE of the PDF. MSE=.0833 Matlab code: function [r0,r1,q,fmin,fmax,MSE] = MSE3() q=1; r0=-.5; r1=.5; fmin=-1; fmax=1; [email protected](x) ((x-r0).^2).*(x+1); [email protected](x) ((x-r1).^2).*(-x+1); MSE=quad(f1,-1,0) + quad(f2,0,1); 4. Used matlab to compute the MMSE. MMSE=.0556 Matlab code: function [MMSE]=MMSE4() [email protected](x) (x.*(x+1)); [email protected](x) (x+1); [email protected](x) (x.*(-x+1)); [email protected](x) (-x+1); r0= (quad(f1,-1,0)/quad(f2,-1,0)); r1=(quad(f3,0,1)/quad(f4,0,1)); [email protected](x) ((x-r0).^2).*(x+1); [email protected](x) ((x-r1).^2).*(-x+1); MMSE=quad(f5,-1,0) + quad(f6,0,1);...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

hw1dip - end end%Quantized to 64 levels y = zeros(size(x...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online