# image_denoise

image_denoise, a MATLAB code which uses the median filter to try to remove noise from an image.

In MATLAB, a black and white or gray scale image can be represented using a 2D array of nonnegative integers over some range 0 to GMAX. The value 0 indicates black, and GMAX white. Intermediate values represent shades of gray in a natural way. Note, however, that the eye has a nonlinear response to intensity, so that the value GMAX/2 will not be perceived as halfway between 0 and GMAX. That is a separate issue.

A color image can be represented using a set of three 2D arrays, which can be thought of as R, G, and B, and which represent the intensity of the red, green and blue signals that combine to form the color image. A common maximum value is assumed, RGBMAX.

An image can be read into MATLAB using the imread function in the Image Processing Toolbox.

A good image is damaged by the addition of "salt and pepper" noise; that is, a scattering of individual pixels have been randomly reset to the lowest or highest possible values. In a gray scale picture, such noise looks as though salt and pepper were added to the picture.

Since an image is fairly "smooth", each good pixel should actually be fairly close to the values of good pixels nearby, while this will not be true for the salt and pepper pixels. So one way to make the noise go away, at the cost of some minor blurring, is to replace each pixel by the median value of itself and its neighbors.

MATLAB provides a command medfilt2 which will do this, with the user allowed to specify the shape of a rectangular neighborhood about each pixel. However, in this example, we go through some of the lower level details "by hand", using finally the median command to get what we want.

Along the way, it should become clear how to deal with grayscale and RGB images. Moreover, some other issues arise, such as ensuring that the processed data retains the "unsigned 8-bit integer" property of the original data.

The functions image_denoise_gray_news and image_denoise_rgb_news use the central pixel and its north, east, west and south neighbors.

The functions image_denoise_gray_3x3 and image_denoise_rgb_3x3 use the central pixel and the entire layer of 8 pixels that lie at most one pixel away in the north/south and east/west directions.

### Languages:

image_denoise is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

image_boundary, a MATLAB code which reports the pixels which form the boundary between the black and white regions of a simple image.

image_components, a MATLAB code which seeks the connected "nonzero" or "nonblack" components of an image or integer vector, array or 3D block.

image_contrast, a MATLAB code which applies image processing techniques to increase the contrast in an image.

image_decimate, a MATLAB code which compresses an image by dropping the even rows and columns of data.

image_diffuse, a MATLAB code which uses diffusion to smooth out an image.

image_double, a MATLAB code which doubles the height and width of an image by repeating each row and column.

image_edge, a MATLAB code which demonstrates a simple procedure for edge detection in images.

image_noise, MATLAB codes which add noise to an image.

image_quantization, a MATLAB code which demonstrates how the KMEANS algorithm can be used to reduce the number of colors or shades of gray in an image.

image_rgb_to_gray, MATLAB codes which makes a grayscale version of an RGB image.

image_threshold, MATLAB codes which make a black and white version of a grayscale image by setting all pixels below or above a threshold value to black or white.

### Reference:

MathWorks documentation for the Image Processing Toolbox is available at https://www.mathworks.com/access/helpdesk/help/pdf_doc/images/images_tb.pdf.

• Jonas Gomes, Luiz Velho,
Image Processing for Computer Graphics,
Springer, 1997,
ISBN: 0387948546,
LC: T385.G65.
• William Pratt,
Digital Image Processing,
Second Edition,
Wiley, 1991,
ISBN13: 978-0471857662,
LC: TA1632.P7.

### Source Code:

Last revised on 03 February 2019.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8878745,"math_prob":0.8143525,"size":3910,"snap":"2021-43-2021-49","text_gpt3_token_len":839,"char_repetition_ratio":0.15488991,"word_repetition_ratio":0.015479876,"special_character_ratio":0.20434782,"punctuation_ratio":0.10391363,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9692646,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-26T08:17:38Z\",\"WARC-Record-ID\":\"<urn:uuid:f9620e3b-dd75-46ad-98e9-7a3476915d08>\",\"Content-Length\":\"8534\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9a066f84-afd6-4f1c-afb9-1ee25e27e1a3>\",\"WARC-Concurrent-To\":\"<urn:uuid:f230d7cb-a639-4490-a5c1-2748c5810a54>\",\"WARC-IP-Address\":\"144.174.16.102\",\"WARC-Target-URI\":\"https://people.sc.fsu.edu/~jburkardt/m_src/image_denoise/image_denoise.html\",\"WARC-Payload-Digest\":\"sha1:FY3DU7457ZNPP72EQO76LM3LNUJQD7RF\",\"WARC-Block-Digest\":\"sha1:OO7F5VYTHIPMLABRB5DJFWOE4LHEXRDU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323587854.13_warc_CC-MAIN-20211026072759-20211026102759-00035.warc.gz\"}"}