Path to mathematics-python computing practice (16)-machine vision-filter noise reduction (neighborhood average method filtering)-python practice

Source: Internet
Author: User

Path to mathematics-python computing practice (16)-machine vision-filter noise reduction (neighborhood average method filtering)-python practice

#-*-Coding: UTF-8-*-# code: myhaspl@myhaspl.com # neighborhood filtering with a radius of 2 import cv2import numpy as npfn = "test3.jpg" myimg = cv2.imread (fn) img = cv2.cvtColor (myimg, cv2.COLOR _ BGR2GRAY) # Add salt and pepper noise param = 20 # grayscale range w = img. shape [1] h = img. shape [0] newimg = np. array (img) # noisecount = 100000for k in xrange (0, noisecount): xi = int (np. random. uniform (0, newimg. shape [1]) xj = int (np. random. uniform (0, newimg. shape [0]) newimg [xj, xi] = 255 # neighborhood average de-noise tmpimg [1: myh-1, 1: myw-1] = newimg [0: myh, 0: myw] # using the domain average method, set the radius to 2, and the impulse response function a = 1/8. 0 kernel = a * np. array ([[, 1], [, 1], [, 1]) ......

The above is the salt and pepper noise filtering.


All content of this blog is original, if reproduced please indicate the source http://blog.csdn.net/myhaspl/


It is processing Gaussian noise filtering, and the effect is indeed good.




Matlab Image smooth processing, using the neighborhood average method and the median filter method to achieve image smooth processing source code (note required)

% Median
I =imread('lena.bmp '); % read the source Image
J1 = imnoise (I, 'Salt & pepper ', 0.02); % salt and pepper noise with an average value of 0 and a variance of 0.02
J2 = imnoise (I, 'gaussian ', 0.02); % gaussian noise with an average value of 0 and a variance of 0.02.
Subplot (, 1), imshow (J1); % displays prepaster noise images
Subplot (, 2), imshow (J2); % displays Gaussian noise images
I1 = medfilt2 (J1, [5, 5]); % Perform 5 × 5 median filter on image with pretzels
I2 = medfilt2 (J2, [5, 5]); % Perform 5 × 5 median filter on Gaussian noise images in a square window
Subplot (, 3), imshow (I1); % the filtering result of the image with pretzels
Subplot (, 4), imshow (I2); % displays the filtering result of an image with Gaussian Noise

% Balance

I =imread('lena.bmp '); % read the graph to I
Imshow (I); % Show Image
Figure, imhist (I); % Histogram
I2 = histeq (I); % balance
Figure; imshow (I2); % displayed after processing
Figure; imhist (I2); % histogram after equalization
Imwrite(I2,'lena2.bmp '); % Save the image

How can the uncertainty of the string vibration experiment be regarded as B or synthesis?

Degrees of Freedom is the number of independent coordinates required to determine the state of an object. According to the energy equi-tion Theorem in Thermodynamic, the energy of each degree of freedom is equal (of course, the quantum effect is not taken into account ), all are Tk/2 (vibration includes kinetic energy and potential energy, so the vibration energy is (Tk/2) * 2), and the single atom has only three degrees of freedom for translation, so it is 3Tk/2, non-rigid dual-Atom Molecules have three degrees of freedom for translation, two degrees of freedom for rotation, and one degree of freedom for vibration. Therefore, they are (3 + 2 + 1*2) Tk/2, non-rigid triplicate sub-molecules have three degrees of freedom, three degrees of freedom, and three degrees of freedom. Therefore, the three degrees of freedom are (3 + 3 + 3*2) Tk/2, rigid molecules do not need to consider vibration. generally non-rigid molecules have 3 * n degrees of freedom, 3 degrees of freedom for translation, 3 degrees of freedom for rotation, (n is the number of atoms, n> 2 ), so there is a vibration Degree of Freedom of n-6. It cannot be said that the energy of each molecule is iTk/2, which is a statistical rule.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.