hw3s - j = 1:n if lenna(i,j) thresh % Thresholding my...

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

View Full Document Right Arrow Icon
ECE 178: HW #3 Solutions Q1 . 0 0 0 0 1 2 3 2 1 0 0 0 0 1 2 3 2 1 x [ - 4] = 1 1 2 3 2 1 x [ - 3] = 4 1 2 3 2 1 x [ - 2] = 10 1 2 3 2 1 x [ - 1] = 16 1 2 3 2 1 x [0] = 19 1 2 3 2 1 x [1] = 16 1 2 3 2 1 x [2] = 10 1 2 3 2 1 x [3] = 4 1 2 3 2 1 x [4] = 1 y [ n ] = £ 1 4 10 16 19 16 10 4 1 / 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Q2 . y [ m,n ] = X k X l x [ k,l ] u [ m - k,n - l ] y [ m,n ] = 5 u [ m,n ] - u [ m - 1 ,n ] - u [ m,n - 1] - u [ m + 1 ,n ] - u [ m,n + 1] -1 n ... . . . . . . ... . . . ... m 1 1 1 1 1 1 1 1 1 2 2 2 3 2 2 2 -1 -1 -1 -1 -1 -1 -1 2
Background image of page 2
Q3 . y [ m,n ] = X k X l x [ k,l ] h [ m - k,n - l ] y [ m,n ] = 3 0 - 1 1 - 3 - 2 1 0 0 1 1 - 2 2 - 2 1 - 1 0 1 0 0 - 1 1 - 2 1 1 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Q4 . clear;close all;clc; lenna=im2double(imread( 'lena.gif' )); %Read the image % Use im2double() to rescale intensities to [0,1] figure; imshow(lenna); % Show the original image title( 'Original Image' ); thresh = 0.5; % Assign the threshold my bin1 = lenna thresh; %Uniform quantization imwrite(my bin1, 'uq.bmp' , 'bmp' ); %Save the output figure; imshow(my bin1); %Show the output title( 'Output of Uniform Quantization' ); my bin2 = logical(zeros(size(lenna))); %Create the second output [m,n] = size(lenna); for i = 1:m for
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: j = 1:n if lenna(i,j) thresh % Thresholding my bin2(i,j) = 1; else my bin2(i,j) = 0; end my error = lenna(i,j)-my bin2(i,j); if ( i == 1 || i == m ... || j == 1 || j == n ) % check if i and j are on borders %Diffuse the error lenna(i,j+1)=lenna(i,j+1)+ 7/16 * my error; lenna(i+1,j-1)=lenna(i+1,j-1)+3/16 * my error; lenna(i+1,j)=lenna(i+1,j)+ 5/16 * my error; lenna(i+1,j+1)=lenna(i+1,j+1)+1/16 * my error; end end end figure; imshow(my bin2); %Show the output title( 'Output of Floyd-Steinberg Algorithm' ); imwrite(my bin2, 'uqd.bmp' , 'bmp' ); %Save the output Original Image Output of Uniform Quantization Output of Floyd-Steinberg Algorithm 4...
View Full Document

This note was uploaded on 06/12/2009 for the course ECE 178 taught by Professor Manjunath during the Winter '08 term at UCSB.

Page1 / 4

hw3s - j = 1:n if lenna(i,j) thresh % Thresholding my...

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