# 1.6 三维卷积（Convolutions over volumes）

3通道的RGB图片对应的滤波器算子也是3通道的。例如一个图片是6 x 6 x 3，分别表示图片的高度（height）、宽度（weight）和通道（#channel）

3通道图片的卷积运算与单通道图片的卷积运算基本一致。过程是将每个单通道（R，G，B）与对应的filter进行卷积运算求和，然后再将3通道的和相加，得到输出图片的一个像素值

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/9b0b0e9062f8814a6a462ea64449f89e.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/9b0b0e9062f8814a6a462ea64449f89e.png)

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/2fd0c97947a3e8222e78d550a317366d.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/2fd0c97947a3e8222e78d550a317366d.png)

不同通道的滤波算子可以不相同。例如R通道filter实现垂直边缘检测，G和B通道不进行边缘检测，全部置零，或者将R，G，B三通道filter全部设置为水平边缘检测

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/d088cafb50cabd6837d95c03c953e920.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/d088cafb50cabd6837d95c03c953e920.png)

为了进行多个卷积运算，实现更多边缘检测，可以增加更多的滤波器组。例如设置第一个滤波器组实现垂直边缘检测，第二个滤波器组实现水平边缘检测。做完卷积，然后把这两个4×4的输出堆叠在一起，第一个放到前面，第二个放到后面，就得到一个4×4×2的输出立方体

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/794b25829ae809f93ac69f81eee79cd1.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/794b25829ae809f93ac69f81eee79cd1.png)

不同滤波器组卷积得到不同的输出，个数由滤波器组决定

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/d590398749e3f5f3ac230ab25116c4b7.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/d590398749e3f5f3ac230ab25116c4b7.png)

若输入图片的尺寸为n x n x$$n\_c$$，filter尺寸为f x f x $$n\_c$$，则卷积后的图片尺寸为(n-f+1) x (n-f+1) x $${n}'\_c$$(默认padding为1）。$$n\_c$$为图片通道数目，$${n}'\_c$$为滤波器组个数


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://baozoulin.gitbook.io/neural-networks-and-deep-learning/di-si-men-ke-juan-ji-shen-jing-wang-luo-convolutional-neural-networks/convolutional-neural-networks/foundations-of-convolutional-neural-networks/16-san-wei-juan-ji-ff08-convolutions-over-volumes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
