In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use Python OpenCV edge filter retention". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Function prototype introduces Gaussian bilateral filtering
The prototype of bilateral filter function is as follows:
Dst = cv2.bilateralFilter (src, d, sigmaColor, sigmaSpace [, dst [, borderType]])
Parameter description:
Src: input ima
D: the diameter range of each pixel neighborhood during the filtering process. If it is not a positive number, the function calculates the value from the parameter sigmaSpace
SigmaColor: the sigma value of the color space filter. The higher the value of the parameter, the wider the color in the neighborhood of the pixel will be mixed, resulting in a larger semi-isochromatic area.
SigmaSpace: the sigma value of the filter in coordinate space. If this value is large, it means that the farther away the pixels will influence each other, so that enough similar colors in the larger area will get the same color. When d > 0, d specifies the neighborhood size and is independent of sigmaSpace, otherwise d is proportional to sigmaSpace.
Dst: an output image of the same size and format as the source image
Generally, the sigmaSpace setting is larger, the sigmaColor setting is smaller, and the final effect is better.
Advantages and disadvantages:
Bilateral filtering can preserve the edge details of the image and filter out the noise of low frequency components, but the bilateral filtering efficiency is not very high and takes longer than other filters.
The test code is as follows, first master the basic use of the function.
Import cv2 as cvimport numpy as np# bilateral filter def bilater (image): # third parameter larger (color), fourth smaller (space) dst = cv.bilateralFilter (image, 0100,15) cv.namedWindow ("dst") cv.imshow ("dst", dst) src = cv.imread (". / 123.jpg") cv.namedWindow ('src') cv.imshow (' src', src) bilater (src) cv.waitKey (0) cv.destroyAllWindows ()
Mean shift filtering
Mean shift algorithm is a general clustering algorithm. Its basic principles are as follows:
For a given number of samples, select one of the samples, delineate a circular region with the sample as the central point, obtain the centroid of the sample in the circular region, that is, the point with the maximum density, and then take this point as the center to continue the above iterative process until the final convergence. (I don't understand it very well, just get to know it.)
The function prototype is as follows:
Dst = cv2.pyrMeanShiftFiltering (src, sp, sr [, dst [, maxLevel [, termcrit])
Parameter description:
Src: input image, 8-bit 3-channel image
Sp: migrate physical space radius siz
Sr: migrate the radius of the color space
Dst: optional parameter, output image of the same size and format as the source image
MaxLevel: optional parameter, maximum number of layers of the pyramid
Termcrit: optional parameter, migration iteration termination condition, can be set to the number of iterations to meet the termination, iteration goal and center point deviation to meet the termination, or a combination of both.
Among all the parameters, sp and sr are required. The higher the value of the two settings, the more obvious the smoothing effect on the image color, and the more time-consuming the function takes.
The test code is as follows:
Import cv2 as cvimport numpy as np# bilateral filter def bilater (image): # the third parameter is larger (color) The fourth smaller point (space) dst = cv.bilateralFilter (image, 0,100,15) cv.namedWindow ("dst") cv.imshow ("dst", dst) # mean shift filtering def pyrmeanshift (src): dst = cv.pyrMeanShiftFiltering (src, 10,50) cv.imshow ("dst", dst) src = cv.imread (". / 123.jpg") cv.namedWindow ('src') cv.imshow (' src') Src) pyrmeanshift (src) cv.waitKey (0) cv.destroyAllWindows () "how to use Python OpenCV Edge filtering Preservation" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.