hw1dip - end end %Quantized to 64 levels y =...

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

View Full Document Right Arrow Icon
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);
Background image of page 1

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

View Full DocumentRight Arrow Icon
%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);
Background image of page 2
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);
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
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; f1=@(x) ((x-r0).^2).*(x+1); f2=@(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() f1=@(x) (x.*(x+1)); f2=@(x) (x+1); f3=@(x) (x.*(-x+1)); f4=@(x) (-x+1); r0= (quad(f1,-1,0)/quad(f2,-1,0)); r1=(quad(f3,0,1)/quad(f4,0,1)); f5=@(x) ((x-r0).^2).*(x+1); f6=@(x) ((x-r1).^2).*(-x+1); MMSE=quad(f5,-1,0) + quad(f6,0,1);...
View Full Document

Page1 / 4

hw1dip - end end %Quantized to 64 levels y =...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online