L24. More on Image File Processing

Slides:



Advertisements
Similar presentations
CS Spring 2009 CS 414 – Multimedia Systems Design Lecture 4 – Digital Image Representation Klara Nahrstedt Spring 2009.
Advertisements

1 Video Processing Lecture on the image part (8+9) Automatic Perception Volker Krüger Aalborg Media Lab Aalborg University Copenhagen
1Ellen L. Walker ImageJ Java image processing tool from NIH Reads / writes a large variety of images Many image processing operations.
Median Filter If the objective is to achieve noise reduction rather than blurring, an alternative approach is to use median filters. That is, the gray.
Insight Through Computing 22. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.
MSU CSE 803 Stockman Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute.
Computer Vision Introduction to Image formats, reading and writing images, and image environments Image filtering.
Image representation using arrays Image processing examples
1 Image Filtering Readings: Ch 5: 5.4, 5.5, 5.6,5.7.3, 5.8 (This lecture does not follow the book.) Images by Pawan SinhaPawan Sinha formal terminology.
Insight Through Computing 18. Two-Dimensional Arrays Set-Up Rows and Columns Subscripting Operations Examples.
1 Image filtering Images by Pawan SinhaPawan Sinha.
Lec 5 Feb 10 Goals: analysis of algorithms (continued) O notation summation formulas maximum subsequence sum problem (Chapter 2) three algorithms image.
Insight Through Computing 23. Working with Image Files Cont’d Filtering Noise Edge Detection.
Matlab Tutorial Continued Files, functions and images.
MSU CSE 803 Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute some result.
Most slides from Steve Seitz
Presentation Image Filters
Digital Image Processing Image Enhancement Part IV.
Digital Image Processing CCS331 Relationships of Pixel 1.
Filtering and Enhancing Images. Major operations 1. Matching an image neighborhood with a pattern or mask 2. Convolution (FIR filtering)
Lecture 03 Area Based Image Processing Lecture 03 Area Based Image Processing Mata kuliah: T Computer Vision Tahun: 2010.
AdeptSight Image Processing Tools Lee Haney January 21, 2010.
Video Segmentation Prepared By M. Alburbar Supervised By: Mr. Nael Abu Ras University of Palestine Interactive Multimedia Application Development.
Image processing Fourth lecture Image Restoration Image Restoration: Image restoration methods are used to improve the appearance of an image.
Chapter 5: Neighborhood Processing
Image Processing Part II. 2 Classes of Digital Filters global filters transform each pixel uniformly according to the function regardless of its location.
Image Subtraction Mask mode radiography h(x,y) is the mask.
Lecture # 19 Image Processing II. 2 Classes of Digital Filters Global filters transform each pixel uniformly according to the function regardless of.
L23. Working with Image Files imread, imwrite, imshow, uint8, rgb2gray.
By Dr. Rajeev Srivastava
CS Spring 2010 CS 414 – Multimedia Systems Design Lecture 4 – Audio and Digital Image Representation Klara Nahrstedt Spring 2010.
Instructor: Mircea Nicolescu Lecture 5 CS 485 / 685 Computer Vision.
Use fuzzy logic to implement a selective median filter to clean noisy images HUI LI BSU11/14/2000.
Non-linear filtering Example: Median filter Replaces pixel value by median value over neighborhood Generates no new gray levels.
Lecture 10 Chapter 5: Image Restoration. Image restoration Image restoration is the process of recovering the original scene from the observed scene which.
Images provided by Ohio University’s Witmer Lab for STEM educational aids for K–12 Researchers conducted a CT scan of the head of a 41-year-old male white.
Motivations Paper: Directional Weighted Median Filter Paper: Fast Median Filters Proposed Strategy Simulation Results Conclusion References.
Computer Application in Engineering Design
(Project) by:- ROHAN HIMANSHU ANUP 70282
Image Subtraction Mask mode radiography h(x,y) is the mask.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Image Pre-Processing in the Spatial and Frequent Domain
IMAGE ENHANCEMENT TECHNIQUES
ECE 692 – Advanced Topics in Computer Vision
Mean Shift Segmentation
Fourier Transform: Real-World Images
Singular Value Decomposition
Image filtering Hybrid Images, Oliva et al.,
Computer Vision Lecture 9: Edge Detection II
CIS 350 – 3 Image ENHANCEMENT SPATIAL DOMAIN
Image filtering Images by Pawan Sinha.
Histogram Probability distribution of the different grays in an image.
Image filtering Images by Pawan Sinha.
Spatial operations and transformations
Technique 6: General gray-level transformations
Drawing the Mandelbrot Set
Colors Computers build colors from Red, Green, and Blue; not Red, Blue, and Yellow. RGB = Red Green Blue Creating Colors Red + Blue = Purple No Red, No.
Digital Image Processing Week IV
Image filtering
Image filtering
Linear Operations Using Masks
Technique 6: General gray-level transformations
Programming for Engineers in Python
Housam Babiker, Randy Goebel and Irene Cheng
L19. Two-Dimensional Arrays
Image Filtering Readings: Ch 5: 5. 4, 5. 5, 5. 6, , 5
Intro Math Problem Solving October 31
Intro Math Problem Solving November 2
Spatial operations and transformations
Number Summaries and Box Plots.
Presentation transcript:

L24. More on Image File Processing Filtering Noise Edge Detection

Pictures as Arrays 0 <= A(i,j) <= 255 A black and white picture can be encoded as a 2D Array Typical: 0 <= A(i,j) <= 255 (black) (white) Values in between correspond to different levels of grayness.

Just a Bunch of Numbers 1458-by-2084 150 149 152 153 152 155 150 149 152 153 152 155 151 150 153 154 153 156 153 151 155 156 155 158 154 153 156 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162

Dirt! 1458-by-2084 Note how the “dirty pixels” look out of place 150 149 152 153 152 155 151 150 153 154 153 156 153 2 3 156 155 158 154 2 1 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162 Note how the “dirty pixels” look out of place

Can We Filter Out the “Noise”?

Idea 1458-by-2084 Assign “typical” neighborhood gray values to 150 149 152 153 152 155 151 150 153 154 153 156 153 ? ? 156 155 158 154 ? ? 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162 Assign “typical” neighborhood gray values to “dirty pixels”

Getting Precise “Typical neighborhood gray values” Could use Median Or Mean radius 1 radius 3 We’ll look at “Median Filtering” first…

Median Filtering Visit each pixel. Replace its gray value by the median of the gray values in the “neighborhood”.

Using a radius 1 “Neighborhood” 6 7 6 7 6 7 Before After

How to Visit Every Pixel m = 9 n = 18 for i=1:m for j=1:n Compute new gray value for pixel (i,j). end

Replace with the median of the values under the window. Original: i = 1 j = 1 Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = 1 j = 2 Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = 1 j = 3 Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = 1 j = n Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = 2 j = 1 Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = 2 j = 2 Filtered: Replace with the median of the values under the window.

Replace with the median of the values under the window. Original: i = m j = n Filtered: Replace with the median of the values under the window.

What We Need… (1) A function that computes the median value in a 2-dimensional array C: m = medVal(C) (2) A function that builds the filtered image by using median values of radius r neighborhoods: B = medFilter(A,r)

If n is even, then use : med = ( x(m) + x(m+1) )/2 Computing Medians x : 21 89 36 28 19 88 43 x = sort(x) x : 19 21 28 36 43 88 89 n = length(x); % n = 7 m = ceil(n/2); % m = 4 med = x(m); % med = 36 If n is even, then use : med = ( x(m) + x(m+1) )/2

Median of a 2D Array function med = medVal(C) [p,q] = size(C); x = []; for k=1:p x = [x C(k,:)]; end Compute median of x and assign to med.

Medians vs Means A = 150 151 158 159 156 153 151 156 155 151 150 155 152 154 159 156 154 152 158 152 152 158 157 150 157 Median = 154 Mean = 154.2

Medians vs Means A = 150 151 158 159 156 153 151 156 155 151 150 155 0 154 159 156 154 152 158 152 152 158 157 150 157 Median = 154 Mean = 148.2

Back to Filtering… m = 9 n = 18 for i=1:m for j=1:n Compute new gray value for pixel (i,j). end

Window Inside… m = 9 n = 18 New gray value for pixel (7,4) = medVal( A(6:8,3:5) )

Window Partly Outside… m = 9 n = 18 New gray value for pixel (7,1) = medVal( A(6:8,1:2) )

Window Partly Outside… m = 9 n = 18 New gray value for pixel (9,18) = medVal( A(8:9,17:18) )

% B from A via median filtering % with radius r neighborhoods. function B = medFilter(A,r) % B from A via median filtering % with radius r neighborhoods. [m,n] = size(A); B = uint8(zeros(m,n)); for i=1:m for j=1:n C = pixel (i,j) neighborhood B(i,j) = medVal(C); end

The Pixel (i,j) Neighborhood iMin = max(1,i-r) iMax = min(m,i+r) jMin = max(1,j-r) jMax = min(n,j+r) C = A(iMin:iMax,jMin:jMax) m A r = 1 r = 2 n

B = medFilter(A)

Original

What About Using the Mean instead of the Median? Replace each gray value with the average gray value in the radius r neighborhood.

Mean Filter with r = 3

Mean Filter with r = 10

Why it Fails The mean does not capture representative values. 85 86 150 149 152 153 152 155 151 150 153 154 153 156 153 2 3 156 155 158 154 2 1 157 156 159 156 154 158 159 158 161 157 156 159 160 159 162 The mean does not capture representative values. 85 86 87 88

And Median Filters Leave Edges (Pretty Much) Alone 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 100 100 200 200 200 100 100 100 200 200 100 100 100 100 200 100 100 100 100 100 Inside the box, the 200’s stay at 200 and the 100’s stay at 100.

Finding Edges

What is an Edge? Near an edge, grayness values change abruptly. 200 200 200 200 200 200 200 200 200 200 200 100 200 200 200 200 100 100 200 200 200 100 100 100 200 200 100 100 100 100 200 100 100 100 100 100

The Rate-of-Change-Array Suppose A is an image array with integer values between 0 and 255 B(i,j) be the maximum difference between A(i,j) and any of its eight neighbors.

Example 59 90 58 60 56 62 65 57 81 Rate-of-change at middle pixel is 30

% B is the corresponding % Rate-Of-Change array function B = Edges(P) % P is a jpeg file % B is the corresponding % Rate-Of-Change array A = rgb2gray(imread(P)); [m,n] = size(A); B = uint8(zeros(m,n)); for i=2:m-1 for j = 2:n-1 B(i,j) = ????? end

Recipe for B(i,j) % The 3-by-3 subarray that includes % A(i,j) and its 8 neighbors… Neighbors = A(i-1:i+1,j-1:j+1); % Subtract A(i,j) from each entry… Diff = Neighbors – A(i,j)); % Take absolute value of each entry.. posDiff = abs(Diff); % Compute largest value in each column… colMax = max(posDiff); % Compute the max of the column max’s… B(I,j) = max(colMax)

Rate-of-Change Array to Image B = Edges('Tower.jpg'); % Compute 0-1 array that identifies % those B entries bigger than 20: importantPixels = B > 20; % Display those pixels with maximum % brightness C = uint8( 255*importantPixels ); imshow(C) B>0 is a 0-1 array, the ones are located where B(i,j)> 20.

Threshhold = 40

Threshhold = 20

Threshhold = 30