This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: #5 ECE 253 Digital Image Processing Pamela Cosman 10/12/10 Solutions to Homework 1 1. Boundary extraction: The bwperim command will work: bw2 = bwmorph(bw,4); The remove command which is part of bwmorph produces the same result: bw3 = bwmorph(bw,’remove’); The approach given in class is to do an erosion, and then subtract the eroded version from the original image: bw6 = bwmorph(bw,’erode’,1); bw7 = bw - bw6; This gives us an inner boundary, that consists of pixels which are part of the original fore- ground connected components. You could get another version of a boundary by using the same approach with a different structuring element, for example a 5x5 structuring element which would give a thicker boundary, or a cross-shaped structuring elements which would give a thin 8-connected boundary. We can get an “outer boundary”, that consists of pixels which are not actually part of the original foreground connected components, by doing a dilation, and then subtracting the original image from the dilated version of it: bw4 = bwmorph(bw,’dilate’,1); bw5 = bw4 - bw; There are various other random things one could call a “boundary” for example do one round of thinning, and then subtract the thinned version from the original image: bw8 = bwmorph(bw,’thin’,1); bw9 = bw - bw8; But this one looks a little weird, which makes sense if you know what the thinning is doing. 2. Adding salt-and-pepper noise: For producing noise by random pixel flipping, the exclusive OR function allows a compact function: 1 function out = ipflip( in, p ) out = xor( in, rand( size(in) ) < (p/100) ); 3. Isolated pixel cleaning: Isolated pixel removal can be achieved several different ways. Here’s a method based on pixel stacking: function out = clean2( noisy ) mask = [ 1 8 64; 2 16 128; 4 32 256]; im2 = filter2(mask,noisy); test = (im2 ~= 16); out = noisy .* test; test = (im2 == 495); out = out + test; Visually, it looks like the low-noise case gets very well cleaned up, but the high-noise case doesn’t get cleaned much at all. This is because in the high-noise case, many of the noise pixels are not isolated.pixels are not isolated....
View Full Document
This note was uploaded on 01/15/2012 for the course ECE ece253A taught by Professor Cosman during the Fall '11 term at UCSD.
- Fall '11
- Image processing