当前位置:网站首页>[200 opencv routines] 99 Modified alpha mean filter
[200 opencv routines] 99 Modified alpha mean filter
2022-07-05 02:30:00 【Xiaobai youcans】
【OpenCV routine 200 piece 】99. Modified alpha mean filter
Welcome to your attention 『OpenCV routine 200 piece 』 series , Ongoing update
Welcome to your attention 『Python Small white OpenCV Learning lessons 』 series , Ongoing update
3.6 Modified alpha mean filter (Modified alpha-mean filter)
The modified alpha mean filter also belongs to statistical sorting filter , The idea is similar to the method of calculating the average score after removing the highest score and the lowest score in the competition .
Make S x y Sxy Sxy Indicates that the center is at the point ( x , y ) (x,y) (x,y) 、 The size is m ∗ n m*n m∗n Rectangular sub window ( Neighborhood ) A set of coordinates , Modified alpha mean filter in S x y Sxy Sxy Defined neighborhood , Delete d The lowest gray value and d The highest gray value , Calculate the remaining pixels g R ( r , c ) g_R(r,c) gR(r,c) The arithmetic mean of is used as the output result , namely :
f ^ ( x , y ) = 1 m n − 2 d ∑ ( r , c ) ∈ S R g R ( r , c ) \hat{f}(x,y) = \frac{1}{mn-2d} \sum _{(r,c) \in S_R} g_R(r,c) f^(x,y)=mn−2d1(r,c)∈SR∑gR(r,c)
d The range of phi is zero [ 0 , m n / 2 − 1 ] [0, mn/2-1] [0,mn/2−1]. choice d The size of has a great influence on the effect of image processing , When d = 0 d=0 d=0 It is simplified as arithmetic average filter , When d = m n / 2 − 1 d=mn/2-1 d=mn/2−1 Reduced to median filter .d When taking other values , It is suitable for dealing with a variety of mixed noise , Such as Gaussian noise and salt and pepper noise .
routine 9.13: Modified alpha mean filter
# 9.13: Modified alpha mean filter (Modified alpha-mean filter)
img = cv2.imread("../images/Fig0507b.tif", 0) # flags=0 Read as grayscale image
img_h = img.shape[0]
img_w = img.shape[1]
m, n = 5, 5
kernalMean = np.ones((m, n), np.float32) # Generate box core
# Edge fill
hPad = int((m-1) / 2)
wPad = int((n-1) / 2)
imgPad = np.pad(img.copy(), ((hPad, m-hPad-1), (wPad, n-wPad-1)), mode="edge")
imgAlphaFilter0 = np.zeros(img.shape)
imgAlphaFilter1 = np.zeros(img.shape)
imgAlphaFilter2 = np.zeros(img.shape)
for i in range(img_h):
for j in range(img_w):
# Neighborhood m * n
pad = imgPad[i:i+m, j:j+n]
padSort = np.sort(pad.flatten()) # Sort the neighborhood pixels by gray value
d = 1
sumAlpha = np.sum(padSort[d:m*n-d-1]) # Delete d Maximum gray value , d Minimum gray value
imgAlphaFilter0[i, j] = sumAlpha / (m*n-2*d) # Arithmetic average the remaining pixels
d = 2
sumAlpha = np.sum(padSort[d:m*n-d-1])
imgAlphaFilter1[i, j] = sumAlpha / (m*n-2*d)
d = 4
sumAlpha = np.sum(padSort[d:m*n-d-1])
imgAlphaFilter2[i, j] = sumAlpha / (m*n-2*d)
plt.figure(figsize=(9, 7))
plt.subplot(221), plt.axis('off'), plt.title("Original")
plt.imshow(img, cmap='gray', vmin=0, vmax=255)
plt.subplot(222), plt.axis('off'), plt.title("Modified alpha-mean(d=1)")
plt.imshow(imgAlphaFilter0, cmap='gray', vmin=0, vmax=255)
plt.subplot(223), plt.axis('off'), plt.title("Modified alpha-mean(d=2)")
plt.imshow(imgAlphaFilter1, cmap='gray', vmin=0, vmax=255)
plt.subplot(224), plt.axis('off'), plt.title("Modified alpha-mean(d=4)")
plt.imshow(imgAlphaFilter2, cmap='gray', vmin=0, vmax=255)
plt.tight_layout()
plt.show()

( At the end of this section )
Copyright notice :
[email protected] Original works , Reprint must be marked with the original link
Copyright 2021 youcans, XUPT
Crated:2022-2-1
Welcome to your attention 『OpenCV routine 200 piece 』 series , Ongoing update
Welcome to your attention 『Python Small white OpenCV Learning lessons 』 series , Ongoing update
【OpenCV routine 200 piece 】01. Image reading (cv2.imread)
【OpenCV routine 200 piece 】02. Image saving (cv2.imwrite)
【OpenCV routine 200 piece 】03. Image display (cv2.imshow)
【OpenCV routine 200 piece 】04. use matplotlib Display images (plt.imshow)
【OpenCV routine 200 piece 】05. The properties of the image (np.shape)
【OpenCV routine 200 piece 】06. Pixel editing (img.itemset)
【OpenCV routine 200 piece 】07. Image creation (np.zeros)
【OpenCV routine 200 piece 】08. Copy of image (np.copy)
【OpenCV routine 200 piece 】09. Image clipping (cv2.selectROI)
【OpenCV routine 200 piece 】10. Image stitching (np.hstack)
【OpenCV routine 200 piece 】11. Split of image channel (cv2.split)
【OpenCV routine 200 piece 】12. Merging of image channels (cv2.merge)
【OpenCV routine 200 piece 】13. The addition of images (cv2.add)
【OpenCV routine 200 piece 】14. The image is added to the scalar (cv2.add)
【OpenCV routine 200 piece 】15. Weighted addition of images (cv2.addWeight)
【OpenCV routine 200 piece 】16. Addition of images of different sizes
【OpenCV routine 200 piece 】17. Gradient switching between two images
【OpenCV routine 200 piece 】18. Mask addition of images
【OpenCV routine 200 piece 】19. The circular mask of the image
【OpenCV routine 200 piece 】20. Bitwise operation of image
【OpenCV routine 200 piece 】21. Image overlay
【OpenCV routine 200 piece 】22. Add non Chinese text to the image
【OpenCV routine 200 piece 】23. Add Chinese text to the image
【OpenCV routine 200 piece 】23. Add Chinese text to the image
【OpenCV routine 200 piece 】24. Affine transformation of image
【OpenCV routine 200 piece 】25. Translation of image
【OpenCV routine 200 piece 】26. The rotation of the image ( Centered on the origin )
【OpenCV routine 200 piece 】27. The rotation of the image ( Centered on any point )
【OpenCV routine 200 piece 】28. The rotation of the image ( Right angle rotation )
【OpenCV routine 200 piece 】29. Image flipping (cv2.flip)
【OpenCV routine 200 piece 】30. Image zooming (cv2.resize)
【OpenCV routine 200 piece 】31. Image pyramid (cv2.pyrDown)
【OpenCV routine 200 piece 】32. Image distortion ( Crosscutting )
【OpenCV routine 200 piece 】33. Composite transformation of image
【OpenCV routine 200 piece 】34. Projection transformation of image
【OpenCV routine 200 piece 】35. Projection transformation of image ( Border filling )
【OpenCV routine 200 piece 】36. Conversion of rectangular coordinates and polar coordinates
【OpenCV routine 200 piece 】37. Gray processing and binary processing of image
【OpenCV routine 200 piece 】38. Inverse color transformation of image ( Image reversal )
【OpenCV routine 200 piece 】39. Linear transformation of image gray
【OpenCV routine 200 piece 】40. Image piecewise linear gray scale transformation
【OpenCV routine 200 piece 】41. Gray scale transformation of image ( Grayscale stratification )
【OpenCV routine 200 piece 】42. Gray scale transformation of image ( Bit plane layering )
【OpenCV routine 200 piece 】43. Gray scale transformation of image ( Logarithmic transformation )
【OpenCV routine 200 piece 】44. Gray scale transformation of image ( Gamma transform )
【OpenCV routine 200 piece 】45. Gray histogram of the image
【OpenCV routine 200 piece 】46. Histogram equalization
【OpenCV routine 200 piece 】47. Image enhancement — Histogram matching
【OpenCV routine 200 piece 】48. Image enhancement — Color histogram matching
【OpenCV routine 200 piece 】49. Image enhancement — Local histogram processing
【OpenCV routine 200 piece 】50. Image enhancement — Histogram statistics image enhancement
【OpenCV routine 200 piece 】51. Image enhancement — Histogram back tracking
【OpenCV routine 200 piece 】52. Image correlation and convolution
【OpenCV routine 200 piece 】53. Scipy Realize image two-dimensional convolution
【OpenCV routine 200 piece 】54. OpenCV Realize image two-dimensional convolution
【OpenCV routine 200 piece 】55. Separable convolution kernel
【OpenCV routine 200 piece 】56. Low pass cartridge filter
【OpenCV routine 200 piece 】57. Low pass Gaussian filter
【OpenCV routine 200 piece 】58. Nonlinear filtering — median filtering
【OpenCV routine 200 piece 】59. Nonlinear filtering — Bilateral filtering
【OpenCV routine 200 piece 】60. Nonlinear filtering — Joint bilateral filtering
【OpenCV routine 200 piece 】61. Guided filtering (Guided filter)
【OpenCV routine 200 piece 】62. Sharpen the image —— Passivation masking
【OpenCV routine 200 piece 】63. Sharpen the image ——Laplacian operator
【OpenCV routine 200 piece 】64. Sharpen the image ——Sobel operator
【OpenCV routine 200 piece 】65. Sharpen the image ——Scharr operator
【OpenCV routine 200 piece 】66. Low pass of image filtering / qualcomm / Band stop / Bandpass
【OpenCV routine 200 piece 】67. Comprehensive application of image enhancement in spatial domain
【OpenCV routine 200 piece 】68. Comprehensive application of image enhancement in spatial domain
【OpenCV routine 200 piece 】69. Discontinuous Fourier coefficients
【OpenCV routine 200 piece 】70. Fourier transform of one-dimensional continuous function
【OpenCV routine 200 piece 】71. Sampling of continuous functions
【OpenCV routine 200 piece 】72. One dimensional discrete Fourier transform
【OpenCV routine 200 piece 】73. Two dimensional continuous Fourier transform
【OpenCV routine 200 piece 】74. Anti aliasing of images
【OpenCV routine 200 piece 】75. Numpy Realize image Fourier transform
【OpenCV routine 200 piece 】76. OpenCV Realize image Fourier transform
【OpenCV routine 200 piece 】77. OpenCV Realize fast Fourier transform
【OpenCV routine 200 piece 】78. Fundamentals of image filtering in frequency domain
【OpenCV routine 200 piece 】79. The basic steps of image filtering in frequency domain
【OpenCV routine 200 piece 】80. Detailed steps of image filtering in frequency domain
【OpenCV routine 200 piece 】81. Gaussian low pass filter in frequency domain
【OpenCV routine 200 piece 】82. Butterworth low pass filter in frequency domain
【OpenCV routine 200 piece 】83. Low pass filtering in frequency domain : Printed text character repair
【OpenCV routine 200 piece 】84. The high pass filter is obtained from the low pass filter
【OpenCV routine 200 piece 】85. Application of high pass filter in frequency domain
【OpenCV routine 200 piece 】86. Frequency domain filtering applications : Fingerprint image processing
【OpenCV routine 200 piece 】87. Frequency domain passivation masking
【OpenCV routine 200 piece 】88. Laplace high pass filter in frequency domain
【OpenCV routine 200 piece 】89. Transfer function of band stop filter
【OpenCV routine 200 piece 】90. Frequency domain notch filter
【OpenCV routine 200 piece 】91. Gaussian noise 、 rayleigh noise 、 Irish noise
【OpenCV routine 200 piece 】92. Exponential noise 、 Uniform noise 、 Salt and pepper noise
【OpenCV routine 200 piece 】93. Histogram of noise model
【OpenCV routine 200 piece 】94. Arithmetic average filter
【OpenCV routine 200 piece 】95. Geometric mean filter
【OpenCV routine 200 piece 】96. Harmonic averaging filter
【OpenCV routine 200 piece 】97. Anti harmonic averaging filter
【OpenCV routine 200 piece 】98. Statistical sorting filter
【OpenCV routine 200 piece 】99. Modified alpha mean filter
【OpenCV routine 200 piece 】100. Adaptive local noise reduction filter
边栏推荐
- Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
- Start the remedial work. Print the contents of the array using the pointer
- Talk about the things that must be paid attention to when interviewing programmers
- Hmi-30- [motion mode] the module on the right side of the instrument starts to write
- [source code attached] Intelligent Recommendation System Based on knowledge map -sylvie rabbit
- How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
- Traditional chips and AI chips
- [技术发展-26]:新型信息与通信网络的数据安全
- Grpc message sending of vertx
- Design and practice of kubernetes cluster and application monitoring scheme
猜你喜欢

Naacl 2021 | contrastive learning sweeping text clustering task

JVM - when multiple threads initialize the same class, only one thread is allowed to initialize

Exploration of short text analysis in the field of medical and health (I)

openresty ngx_lua執行階段

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/22/08617736a8b943bc9c254aac60c8cb.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)

Stored procedure and stored function in Oracle

Single line function*

Visual explanation of Newton iteration method
随机推荐
R language uses logistic regression and afrima, ARIMA time series models to predict world population
The database and recharge are gone
When to catch an exception and when to throw an exception- When to catch the Exception vs When to throw the Exceptions?
[技术发展-26]:新型信息与通信网络的数据安全
【LeetCode】106. Construct binary tree from middle order and post order traversal sequence (wrong question 2)
Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
Luo Gu Pardon prisoners of war
Missile interception -- UPC winter vacation training match
【LeetCode】501. Mode in binary search tree (2 wrong questions)
Kotlin - 协程 Coroutine
How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
GFS分布式文件系统
【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Icu4c 70 source code download and compilation (win10, vs2022)
Which common ports should the server open
[understanding of opportunity -38]: Guiguzi - Chapter 5 flying clamp - warning one: there is a kind of killing called "killing"
Unpool(nn.MaxUnpool2d)
tuple and point
Character painting, I use characters to draw a Bing Dwen Dwen