<< Chapter < Page Chapter >> Page >

Smoothing

// smoothed_glass // smoothing filter, adapted from REAS:// http://processing.org/learning/topics/blur.html size(210, 170);PImage a; // Declare variable "a" of type PImage a = loadImage("vetro.jpg"); // Load the images into the programimage(a, 0, 0); // Displays the image from point (0,0)// corrupt the central strip of the image with random noise float noiseAmp = 0.2;loadPixels(); for(int i=0; i<height; i++) { for(int j=width/4; j<width*3/4; j++) { int rdm = constrain((int)(noiseAmp*random(-255, 255) +red(pixels[i*width + j])), 0, 255);pixels[i*width + j] = color(rdm, rdm, rdm);} }updatePixels();int n2 = 3/2; int m2 = 3/2;float val = 1.0/9.0; int[][] output = new int[width][height];float[][]kernel = { {val, val, val}, {val, val, val},{val, val, val} };// Convolve the image for(int y=0; y<height; y++) { for(int x=0; x<width/2; x++) { float sum = 0;for(int k=-n2; k<=n2; k++) { for(int j=-m2; j<=m2; j++) { // Reflect x-j to not exceed array boundaryint xp = x-j; int yp = y-k;if (xp<0) { xp = xp + width;} else if (x-j>= width) { xp = xp - width;} // Reflect y-k to not exceed array boundaryif (yp<0) { yp = yp + height;} else if (yp>= height) { yp = yp - height;} sum = sum + kernel[j+m2][k+n2] * red(get(xp, yp));} }output[x][y]= int(sum); }}// Display the result of the convolution // by copying new data into the pixel bufferloadPixels(); for(int i=0; i<height; i++) { for(int j=0; j<width/2; j++) { pixels[i*width + j]= color(output[j][i], output[j][i], output[j][i]);} }updatePixels();

For the purpose of smoothing, it is common to create a convolution mask by reading the values of aGaussian bell in two variables. A property of gaussian functions is that their Fourier transform is itself gaussian. Therefore, impulse response and frequency response have the same shape. However, the transform of a thin bell is a large bell, and vice versa. The larger the bell, the more evident thesmoothing effect will be, with consequential loss of details. In visual terms, a gaussian filter produces an effect similar to that of an opalescent glass superimposed over the image. An example of Gaussian bell is 1 273 1 4 7 4 1 4 16 26 16 4 7 26 41 26 7 4 16 26 16 4 1 4 7 4 1 .

Conversely, if the purpose is to make the contours and salient tracts of an image more evident ( edge crispening or sharpening), we have to perform a high-pass filtering. Similarly to what we saw in [link] this can be done with a convolution matrix whose central value has opposite sign as compared tosurrounding values. For instance, the convolution matrix -1 -1 -1 -1 9 -1 -1 -1 -1 produces the effect of [link] .

Edge crispening

Non-linear filtering: median filter

A filter whose convolution mask is signal-dependent looses its characteristics of linearity. Median filters use themask to select a set of pixels of the input images, and replace the central pixel of the mask with the medianvalue of the selected set. Given a set of N (odd) numbers, the median element of the set is the one that separates N 1 2 smaller elements from N 1 2 larger elements. A typical median filter mask is cross-shaped. For example, a 3 3 mask can cover, when applied to a certain image point, the pixels with values x 4 x 7 99 12 x 9 x , thus replacing the value 99 with the mean value 9 .

Questions & Answers

how to create a software using Android phone
Wiseman Reply
how
basra
what is the difference between C and C++.
Yan Reply
what is software
Sami Reply
software is a instructions like programs
Shambhu
what is the difference between C and C++.
Yan
yes, how?
Hayder
what is software engineering
Ahmad
software engineering is a the branch of computer science deals with the design,development, testing and maintenance of software applications.
Hayder
who is best bw software engineering and cyber security
Ahmad
Both software engineering and cybersecurity offer exciting career prospects, but your choice ultimately depends on your interests and skills. If you enjoy problem-solving, programming, and designing software syste
Hayder
what's software processes
Ntege Reply
I haven't started reading yet. by device (hardware) or for improving design Lol? Here. Requirement, Design, Implementation, Verification, Maintenance.
Vernon
I can give you a more valid answer by 5:00 By the way gm.
Vernon
it is all about designing,developing, testing, implementing and maintaining of software systems.
Ehenew
hello assalamualaikum
Sami
My name M Sami I m 2nd year student
Sami
what is the specific IDE for flutter programs?
Mwami Reply
jegudgdtgd my Name my Name is M and I have been talking about iey my papa john's university of washington post I tagged I will be in
Mwaqas Reply
yes
usman
how disign photo
atul Reply
hlo
Navya
hi
Michael
yes
Subhan
Show the necessary steps with description in resource monitoring process (CPU,memory,disk and network)
samuel Reply
What is software engineering
Tafadzwa Reply
Software engineering is a branch of computer science directed to writing programs to develop Softwares that can drive or enable the functionality of some hardwares like phone , automobile and others
kelvin
if any requirement engineer is gathering requirements from client and after getting he/she Analyze them this process is called
Alqa Reply
The following text is encoded in base 64. Ik5ldmVyIHRydXN0IGEgY29tcHV0ZXIgeW91IGNhbid0IHRocm93IG91dCBhIHdpbmRvdyIgLSBTdGV2ZSBXb3puaWFr Decode it, and paste the decoded text here
Julian Reply
what to do you mean
Vincent
hello
ALI
how are you ?
ALI
What is the command to list the contents of a directory in Unix and Unix-like operating systems
George Reply
how can i make my own software free of cost
Faizan Reply
like how
usman
hi
Hayder
The name of the author of our software engineering book is Ian Sommerville.
Doha Reply
what is software
Sampson Reply
the set of intruction given to the computer to perform a task
Noor
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Media processing in processing. OpenStax CNX. Nov 10, 2010 Download for free at http://cnx.org/content/col10268/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Media processing in processing' conversation and receive update notifications?

Ask