ECE 480 Lab
9
Ryan Eslinger and Mike Fuson
16 February 2011
Circles Erroded Circles Histogram of Circles
To count the Circles we used the ultimate point command in ImageJ which returns a pixel in the position of the original shape and gives the pixel a grey value equal to the radius of the shape. We then looked at the histogram of this output which told us that there were 3 circles with radius of 16, 7 with radius 17, 10 with radius 20 and 4 with radius 54.
Paragraph letter
b hit-or-miss output
To
count the occurrences of the letter b we used the following MATLAB code. At the end of the code it would output the
variable count which equaled the number of occurrences. In this case it was 5.
% Michael
Fuson
% Ryan
Eslinger
% ECE480
% Lab9
clear;
clc;
img = im2single(rgb2gray(imread('black cat words.bmp')));
% hhist2d = video.Histogram;
% prob_dist
= step(hhist2d,img).';
for i=1:283
for j=1:729
if img(i,j)>.5
img(i,j)=1;
else
img(i,j)=0;
end
end
end
y=1;
for i=17:77
x=1;
for j=143:185
b(y,x)=img(i,j);
x=x+1;
end
y=y+1;
end
figure
imshow(img)
figure
imshow(b)
output=bwhitmiss(img,b);
output=+output;
figure
imshow(output)
count = 0;
for j = 2:282
for i = 2:728
if output(j,i) == 1 && output(j+1,i+1) == 0 &&
output(j-1,i-1)== 0 && output(j-1,i+1) == 0 && output(j+1,i-1)
== 0 && output(j+1,i) == 0 && output(j-1,i) == 0 &&
output(j,i+1) == 0 && output(j,i-1) == 0
count = count + 1;
else
end
end
end
count
We feel like we succeeded in
this lab as we correctly counted the number of circles and letter b’s.
ECE 480 Lab 8
Ryan Eslinger and Mike Fuson
15 February 2011
We were not able to make the Huffman code work in Matlab but what we tried to do is the following. First we took the histories of the image then arranged the values according to their probability. We then added the least probable values and resorted the array. It was difficult to figure out how to track the resorting and making a tree that could then be used to produce the actual code. We would do this till the there were only two values left and then go down the tree to produce the code.
Lossless:
Start Lossless Code Lossless deCode
The decoded image was the exact same as the original. All detail was retained.
%Michael Fuson
%Ryan Eslinger
%ECE 480
%Lab8 Lossless
lena = im2single(rgb2gray(imread('lena.jpg')));
imshow(lena);
figure(1),title('Lena');
lenacode = lena;
for j = 1:512
pred = lena(j,1);
for i = 1:512
lenacode(j,i)
= lenacode(j,i) - pred;
lenacode(j,1) = lena(j,1);
pred = lenacode(j,i);
end
end
figure(2)
imshow(lenacode);
title('LosslessLena');
lenadecode = lenacode;
for j = 1:512
predde = lenacode(j,1);
for
i = 1:512
lenadecode(j,i) = lenacode(j,i) + predde;
predde = lenacode(j,i);
end
lenadecode(j,1) = lenacode(j,1);
end
figure(3)
imshow(lenadecode);
title('Lena
Decode');
Lossy:
Start Lossy Code Delta = 0.1 Lossy deCode Delta = 0.1
Lossy Code Delta = 0.3 Lossy deCode Delta = 0.3
In both cases the decoded image was not the same as the original. Details were lost. The Step size of 0.1 was closer to the original when decoded.
%Michael Fuson
%Ryan Eslinger
%ECE 480
%Lab8 Lossy
lena = im2single(rgb2gray(imread('lena.jpg')));
imshow(lena);
figure(1),title('Lena');
lenacode = lena;
delt = .1;
for j = 1:512
pred = lena(j,1);
for
i = 1:512
diff
= lenacode(j,i) - pred;
lenacode(j,1) = lena(j,1);
if
diff >= 0
pred = pred
+ delt;
lenacode(j,i) = delt;
else
pred = pred
- delt;
lenacode(j,i) = -delt;
end
end
end
figure(2)
imshow(lenacode);
title('LosslessLena');
lenadecode = lenacode;
for j = 1:512
predde = lenacode(j,1);
for
i = 1:512
lenadecode(j,i) = lenacode(j,i) + predde;
predde = lenadecode(j,i);
end
lenadecode(j,1) = lenacode(j,1);
end
figure(3)
imshow(lenadecode);
title('Lena
Decode');
We feel that we successfully completed this lab.
ECE 480 Lab 7
Ryan Eslinger and Mike Fuson
26 January 2011
Compression:
For the Boats compression we used a threshold of 100 and for the Bridge we used the default threshold of 10. For the Boats image the file size went from 55KB to 46KB and for the Bridge image the file size went from 61 KB to 58KB. This shows that changing the threshold changes how much the image is compressed using the FSW module.
Boats Original Boats Compressed
Bridge Original Bridge Compressed
Filter:
For the filtering we used the FSW transform plugin. We did three iterations of the wavelet algorithm on each image and then removed the top left portion of the picture that represented an average of the picture. We then ran the process in reverse and obtained the images shown. The resulting images contain the edges of the picture which means that the process acted like a highpass filter. There was also a lot of ringing in the images which is indicative of a very sharp filter.
We also used different wavelets and repeated the process. For the different wavelets the intermediate pictures looked very different but the end results were very similar.
Boats Original Proc-Boats WT-Boats Boats 3iterations
Boats 3iterations filtered boats 3iterations reconstructed Boats with edges reconstructed
Bridge Original Proc-Bridge WT-Bridge
Bridge 3iteration Bridge 3iteration filtered
Bridge Orth Bridge B4 Bridge Dual
We feel that we successfully completed this lab.
ECE 480 Lab
6
Ryan Eslinger and Mike Fuson
19 January 2011
Benham’s Disc:
Below is a picture of our Benham Disk stationary and
rotation. No color is visible on the picture in motion because the color effect
is produced by the actual spinning of the disk. It is not complete understood
why this pattern produces colors while moving. One theory is that the three
different cones in the eye have different delays in their perception so somehow
when the motion is at the right frequency color is perceived to appear
Color Brightening:
RGB:
Histogram Blue Equalized Histogram Blue
Equalized Blue Restack New Image
HSB:
Original Stack Hue Saturation Brightness
Histogram Brightness Equalized Histogram Brightness
Equalized Brightness Restack New Image
As learned in class,
modifying just one color affects the other colors when it is restacked. The colors were changed. By modifying the brightness in the HSB
components, none of the colors were changed and the image simply became
brighter.
Pseudo Color Using Look Up Tables:
We feel that we successfully completed this lab.
Ryan Eslinger and Mike Fuson
12 January 2011
Slow
Blur Method and Results:
Stationary Image Blurred Image Deblurred Image
% Michael Fuson
% Slow clock deblurr
slowblurr = im2double(imread('clock moving
slowly.bmp'));
figure(1),title('clock
moving slowly');
PSF=fspecial('motion',Len,Theta);
estimated_nsr
= noise_var / var(slowblurr(:));
Rslowblur = deconvwnr(slowblurr, PSF, estimated_nsr);
title('Restoration
of Blurred Image')
Rapid
Blur Method and Results:
Stationary Image Blurred Image Deblurred Image
% Michael Fuson
% Ryan Eslinger
% ECE480
rapidblurr = im2double(imread('clock moving
rapidly.bmp'));
figure(1),title('clock moving rapidly');
PSF=fspecial('motion',Len,Theta);
estimated_nsr = noise_var / var(rapidblurr(:));
Rrapidblur = deconvwnr(rapidblurr, PSF, estimated_nsr);
figure(115), imshow(Rrapidblur)
title('Restoration
of Blurred Image')
As mentioned in class it was very difficult to do this lab with great success. While we managed to deblur the slow moving clock fairly successfully, we found the rapid moving clock to be much more difficult. We do however feel that we did make an improvement to the rapid clock particularly around the T and the lower dial.
ECE 480 Lab
4
5 January 2011
Large Pinhole
Large Pinhole Convolution Large Pinhole
Correlation
Small Pinhole Small Pinhole
Convolution Small Pinhole Correlation
Two Pinholes
Two Pinholes Convolution Two Pinholes
Correlation
Dots Original
Dots Correlation
Commentary On Part 2:
When we convolved the images
with themselves we saw the pinholes that were originally used to make the
images.
Commentary On Part 3:
The diameter of the circles
was 43 pixels while the distance between the minima and the central maximum was
44 pixels.
We have
completed the lab and believe we were successful in doing so.
ECE 480 Lab
3
Ryan Eslinger and Mike Fuson
15 December 2010
Filter to Remove Sinusoid Image After Sinusoid
FFT After Sinusoid
Image After Median Filter FFT After Median Histogram After
Median
Image After Enhance FFT After Enhance Histogram After
Enhance
Image After Simple Median Only
First we took an FFT of the
original image. We located the sinusoid
and made a filter with two black circles at the location of the sinusoid. We blurred these black dots with a Gaussian
filter to reduce ringing. We then did a
custom FFT filter with our filter to remove the sinusoid. Next we did a median filter to remove the
shot noise. Finally we enhanced the
image using the equalize function.
We feel that the lab was
successful as we removed the noise from the image.
Ryan Eslinger and Mike Fuson
8 December 2010
Histogram Before Histogram After
First
we equalized the image.
We used a
median filter to remove the shot noise.
Simple Average Mask Simple Average Image
Weighted Average Mask Weighted Average
Image
Horizontal Sobel Mask Horizontal Sobel Image
Vertical Sobel
Mask Vertical Sobel
Image
Laplacian
Mask Laplacian Image
In order to add these masks
we used ImageJ’s convolve option which is located under Process\Filters. We then simply typed in the filters that we
wished to use. The simple average mask
blurred the image. The weighted average
mask blurred the
image and brightened the image.The Sobel masks detected edges in one direction. The Laplacian Mask detected all edges.
// This macro creates a sine image
newImage("Sine wave", "32-bit black",
width, height, 1);
if (y%20==0) showProgress(y, height);
// makeLine(0, 0, width, height);
function f0(x) {return 2*x*x-3;}
function f1(x,y) {return sin(1/3x);}
function f2(x,y) {return sin(x/2+y/3)+sin(y/3);}
function f3(x) {return sqrt(x);}
function f4(x) {if (x==0) return 0; else return log(x);}
function f5(x) {return exp(x/100);}
Sinusoidal Image Power Spectra Phase Spectra FFT Plot of Imaginary
// This macro creates a sine image
newImage("Sine wave", "32-bit
black", width, height, 1);
if (y%20==0) showProgress(y, height);
// makeLine(0, 0, width, height);
function f0(x) {return 2*x*x-3;}
function f1(x,y) {return sin(1/3x);} *Note the
1/3 is where we changed the frequency
function f2(x,y) {return sin(x/2+y/3)+sin(y/3);} first
we changed it to 1/10 and then 2
function f3(x) {return sqrt(x);}
function f4(x) {if (x==0) return 0; else return
log(x);}
function f5(x) {return exp(x/100);}
This plot is a a sinusoid at frequency 1/10. Notice how close the dots
are on the Power Spectrum plot.
Sinusoidal Image w/Frequency 1/10 Power Spectra
This plot is a a sinusoid at frequency 2. Notice how far apart the dots
are on the Power Spectrum plot.
Sinusoidal Image w/ Frequency 2 Power Spectra
// This macro creates a sine image
newImage("Sine wave", "32-bit
black", width, height, 1);
if (y%20==0) showProgress(y, height);
// makeLine(0, 0, width, height);
function f0(x) {return 2*x*x-3;}
function f1(x,y) {return sin(1/3x+0.2);}
function f2(x,y) {return sin(x/2+y/3)+sin(y/3);}
function f3(x) {return sqrt(x);}
function f4(x) {if (x==0) return 0; else return
log(x);}
function f5(x) {return exp(x/100);}
Sinusoidal Image Power Spectra Phase Spectra Plot of Imaginary
// This macro creates a sine image
newImage("Sine wave", "32-bit
black", width, height, 1);
if (y%20==0) showProgress(y, height);
// makeLine(0, 0, width, height);
function f0(x) {return 2*x*x-3;}
function
f1(x,y) {return cos(x/4+y/5);}
function f2(x,y) {return sin(x/2+y/3)+sin(y/3);}
function
f3(x) {return sqrt(x);}
function
f4(x) {if (x==0) return 0; else return log(x);}
function
f5(x) {return exp(x/100);}
Sinusoidal Image Power
Spectrum
All these plots were pretty
straight forward and show how Fourier analysis gives us information about the
frequency content of images.
ECE 480 Lab
1
Figure 1:
Squares done using ImageJ
Figure 2: Arrows done using ImageJ
%ILLUSION Creates a famous optical illusion
% ILLUSION(ROWS, COLS) Allows user to specify illusion dimensions
% (ROWS and COLS should be integers)
% illusion; %draws the illusion with 7 rows and 15 columns
% illusion(9,11); %draws the illusion with 9 rows and 11 columns
% Email: jdkirk630 at gmail dot com
if nargin < 2
rows = 7;
rows = max(3,ceil(abs(rows(1))));
cols = max(5,ceil(abs(cols(1))));
illusion(1:2:rows,3:4:2*cols) = 0;
illusion(2:2:rows,1:4:2*cols) = 0;
figure('Name','Optical Illusion','Numbertitle','off','Menubar','none');
axes('Units','normalized','Position',[.05 .05 .9 .85]);
line([1/2 2*(cols+1)], [r r], 'color', 'b', 'linewidth', 2)
title(' Do the blue lines look parallel to you? ')
axis([1/2 2*cols+1/2 1/2 rows+1/2])
Figure 3: Optical illusion from
internet compiled using previous MATLAB code