当前位置:网站首页>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;
}
};边栏推荐
- Acwing第 61 场周赛【完结】
- VM virtual machine has no un bridged host network adapter, unable to restore the default configuration
- 2.9.4 Ext JS的布尔对象类型处理及便捷方法
- firewall 命令简单操作
- 荐书 |《学者的术与道》:写论文是门手艺
- 图论:拓扑排序
- Acwing game 61 [End]
- Go Plus Security:一款Build Web3不可或缺的安全生态基础设施
- How to choose the key words of the thesis?
- 雅迪高端之后开始变慢
猜你喜欢

吴恩达机器学习课后习题——逻辑回归

华为再发“天才少年”全球召集令,有人曾放弃360万年薪加入

Seat / safety configuration upgrade is the administrative experience of the new Volvo S90 in place

文献|关系研究能得出因果性结论吗

Synchronous FIFO based on shift register

Pathmatchingresourcepatternresolver parsing configuration file resource file

How mantium uses deepspeed to implement low latency gpt-j reasoning on Amazon sagemaker

软模拟光栅化渲染器

Inventory the concept, classification and characteristics of cloud computing

firewall 命令简单操作
随机推荐
2022 Hangzhou Electric Multi school bowcraft
[C language foundation] 13 preprocessor
Synchronous FIFO based on shift register
What are the differences between vite and wenpack?
Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
How to choose the key words of the thesis?
Luoda development - audio stream processing - AAC / loopbacktest as an example
生活相关——十年的职业历程(转)
Pat class a 1039 course list for student
(翻译)按钮位置约定能强化用户使用习惯
ROS2的launch有何不同?
Trust sums two numbers
JS get some attributes of the object
Luoda Development -- the context of sidetone configuration
This article takes you to graph transformers
支持代理直连Oracle数据库,JumpServer堡垒机v2.24.0发布
Day24 job
Lua and go mixed call debugging records support cross platform (implemented through C and luajit)
Overview of wavelet packet transform methods
Segger embedded studio cannot find xxx.c or xxx.h file