当前位置:网站首页>Li Kou daily question - day 42 -661. Picture smoother
Li Kou daily question - day 42 -661. Picture smoother
2022-07-26 04:18:00 【Chongyou research Sen】
2022.7.25 Did you brush the questions today ?
subject :
Image smoother It's the size of 3 x 3 Filter , Used to smooth each cell of the image , The value of the cell after smoothing is the average gray level of the cell .
Of each cell Average grayscale Defined as : The cell itself and its surroundings 8 Average of cells , The result needs to be rounded down .( namely , You need to calculate... In the blue smoother 9 Average of cells ).
If there is a missing cell around a cell , The missing cells are not considered when calculating the average gray level ( namely , You need to calculate... In the red smoother 4 Average of cells ).

analysis :
A two-dimensional array , Find the effective lattice around each lattice ( Valuable ) Average value , Then the average value of each two-dimensional array element is calculated to construct a new two-dimensional array .
Ideas : First, make it convenient for two-dimensional arrays , For the first 【0】【0】 Subscript element , We look around it 8 Lattice , And find 【0】【1】 The surrounding 8 Lattice , For this 8 Judge whether it is effective by a grid, and then calculate the average value .
analysis :
1. Violence law
class Solution {
public:
vector<vector<int>> imageSmoother(vector<vector<int>>& img) {
int m = img.size(), n = img[0].size();
vector<vector<int>> ret(m, vector<int>(n));
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
int num = 0, sum = 0;
for (int x = i - 1; x <= i + 1; x++) {
for (int y = j - 1; y <= j + 1; y++) {
if (x >= 0 && x < m && y >= 0 && y < n) {
num++;
sum += img[x][y];
}
}
}
ret[i][j] = sum / num;
}
}
return ret;
}
};边栏推荐
- Educational Codeforces Round 132 (Rated for Div. 2) E. XOR Tree
- [project chapter - how to write and map the business model? (3000 word graphic summary suggestions)] project plan of innovation and entrepreneurship competition and application form of national Entrep
- How to make your language academic when writing a thesis? Just remember four sentences!
- Recommendation Book Educational Psychology: a book for tomorrow's teachers~
- Acwing game 61 [End]
- Under the high debt of Red Star Macalline, is it eyeing new energy?
- Web Test Method Encyclopedia
- 零售连锁门店收银系统源码管理商品分类的功能逻辑分享
- Helloworld案例分析
- [question 019: what is the understanding of spherecastcommand in unity?]
猜你喜欢

Mantium 如何在 Amazon SageMaker 上使用 DeepSpeed 实现低延迟 GPT-J 推理

Huawei executives talk about the 35 year old crisis. How can programmers overcome the worry of age?

【SVN】一直出现 Please execute the ‘Cleanup‘ command,cleanup以后没有反应的解决办法
![[project chapter - how to write and map the business model? (3000 word graphic summary suggestions)] project plan of innovation and entrepreneurship competition and application form of national Entrep](/img/e8/b115b85e2e0547545e85b2058a9bb0.png)
[project chapter - how to write and map the business model? (3000 word graphic summary suggestions)] project plan of innovation and entrepreneurship competition and application form of national Entrep

1. Excel的IF函数

Overview of wavelet packet transform methods

当你尝试删除程序中所有烂代码时 | 每日趣闻

Working ideas of stability and high availability guarantee

Pat class a 1039 course list for student

Wu Enda's machine learning after class exercises - linear regression
随机推荐
(翻译)按钮位置约定能强化用户使用习惯
LeetCode:1184. 公交站间的距离————简单
Dijango learning
2021 CIKM |GF-VAE: A Flow-based Variational Autoencoder for Molecule Generation
Day24 job
Unable to find sygwin.s file during vscode debugging
Method of test case design: introduction, trial recruit, preliminary exploration of equivalence boundary
生活相关——十年的职业历程(转)
Leetcode:1184. Distance between bus stops -- simple
[SVN] please execute the 'cleanup' command appears all the time. The solution is that there is no response after cleanup
How to write abstract in English thesis?
Recommendation | scholar's art and Tao: writing papers is a skill
Matlab drawing
1. Excel的IF函数
Comprehensive evaluation and decision-making method
AcWing. 102 best cattle fence
力扣每日一题-第42天-661. 图片平滑器
(翻译)网站流程图和用户流程图的使用时机
Share | 2022 big data white paper of digital security industry (PDF attached)
What are the duplicate check rules for English papers?