3750. 开卷!

Let's convolve!

time limit per test: 1s

memory limit per test:256MB


Description:

Convolution is a mathematical operation widely used in the fields of signal processing and image processing. In computer vision, convolution is commonly used for feature extraction of images.


Simply put, convolution operation is the mathematical operation of two functions (such as image and convolution kernel) to generate another function (such as feature mapping). This process can be seen as a weighted sum operation between two functions.


In image processing, convolution is usually calculated on the image by sliding the convolutional kernel. A convolutional kernel is a small matrix that contains a set of weights. Multiply and sum the convolution kernel with a small part of the image to obtain a pixel value of the convolution result. Then, continue sliding the convolutional kernel to the next position and perform the multiplication and summation operation again to obtain the next pixel value. Repeat this process until the entire image is traversed, and the result of the convolution operation, namely feature mapping, is obtained.


Convolutional operations are widely used in computer vision, such as edge detection, blur processing, image enhancement, etc. It can extract rich feature information from the original image, providing a foundation for subsequent image analysis and processing.


I believe everyone has learned convolution, so let's do a simple two-dimensional convolution. Let's convolve!


Input Format:

The first line of input   represents the number of rows and columns in the matrix 

Next  lines input the pending matrix 

Next three lines input the   convolutional kernel in the next three lines

The input number range is natural number of int type range


Output Format:

New matrix produced after output convolution Separate each number with a space


Input Case:

5
3 3 2 1 0
0 0 1 3 1
3 1 2 2 3
2 0 0 2 2
2 0 0 0 1
0 1 2
2 2 0
0 1 2


Output Case:

12 12 17
10 17 19 
9 6 14

image.png





开卷!

时间限制:1s

内存限制:256MB


题目描述

卷积是一种数学运算,广泛应用于信号处理和图像处理领域。在计算机视觉中,卷积通常用于图像的特征提取。


简单地说,卷积操作是将两个函数(例如图像和卷积核)进行数学上的运算,生成另一个函数(例如特征映射)。这个过程可以看作是在两个函数之间进行加权求和的操作。


在图像处理中,卷积通常通过滑动卷积核在图像上进行计算。卷积核是一个小的矩阵,包含了一组权重。将卷积核与图像的一个小部分进行对应元素的相乘并求和,得到卷积结果的一个像素值。然后,将卷积核继续滑动到下一个位置,再次进行相乘求和的操作,得到下一个像素值。重复这个过程,直到遍历完整个图像,就得到了卷积操作的结果,即特征映射。


卷积操作在计算机视觉中的应用非常广泛,例如边缘检测、模糊处理、图像增强等。它能够从原始图像中提取出丰富的特征信息,为后续的图像分析和处理提供基础。


相信大家已经学会了卷积,那我们来做一下简单的二维卷积,开卷!


输入格式

第一行输入  代表矩阵的行列数 


接下来  行输入待处理矩阵 


接下来  行输入  的卷积核 


输入数字是 int 类型范围的自然数


输出格式

输出卷积后生产的新矩阵,每个数字用空格隔开


输入样例

5
3 3 2 1 0
0 0 1 3 1
3 1 2 2 3
2 0 0 2 2
2 0 0 0 1
0 1 2
2 2 0
0 1 2


输出样例

12 12 17
10 17 19 
9 6 14

image.png

难度等级: 0
总通过次数: 25
总提交次数: 374