Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions doc/filter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Filter 插件
# Filter Plug-in

Filter是最重要的一类插件,用于对二维图像进行滤波,也是图像处理中最基础,最普遍的一类应用。
Filter is the most important class of plug-ins, which is used to filter two-dimensional images. And it is also the most basic image processing and the most common applications.



Expand All @@ -17,7 +17,7 @@ class Invert(Filter):
return 255-snap
```

Invert插件,`note`指明插件支持任何类型,并且支持`roi`,支持撤销。我们在`run`里面返回处理后的结果。关于`snap`和`img`,`img`是当前图像,而如果当`note`中加入`auto_snap`标识,在`run`之前,框架会帮我们把`img`拷贝给`snap`,因为多数的滤波器需要一个`buffer`来卷积,此外撤销和`roi`支持也必须借助`snap`。
Invert plug-in. The ` note ` indicates the plugin supports any type as well as ` roi ` and the undo operation. We return processing results to the ` run `. About ` snap ` and ` img `, the ` img ` is the current image. When ` note ` is added to ` auto_snap ` logo, the framework will help us to copy ` img ` to ` snap ` before ` run `. Because most of the filter need a ` buffer ` for convolution. Moreover the cancellation operation and ` roi ` support must also need the ` snap `.

![14](http://idoc.imagepy.org/demoplugin/13.png)

Expand All @@ -41,64 +41,64 @@ class Gaussian(Filter):
gaussian_filter(snap, para['sigma'], output=img)
```

Gaussian插件,`note`指明支持任何类型,并且支持`roi`,支持撤销,并提供预览功能。`para`和`view`指明有一个浮点参数`sigma`,而`run`里,我们调用`scipy.ndimage.gaussian_filter`,对`snap`进行滤波,输出指向`img`,如果函数不带输出项,我们将处理结果`return`即可,框架会帮我们赋值给`img`。
Gaussian plug-in. The ` note ` specifies any type support, and supports the ` roi ` as well as cancellation, which provides the preview function. The ` para ` and ` view ` indicate there is a floating point parameters ` sigma `. In ` run `, we can call ` scipy. ndimage. gaussian_filter ` to filter ` snap ` with the output to ` img `. If a function without output item, we will process the results ` return `. And framework will help us to assign a value to ` img `.

![14](http://idoc.imagepy.org/demoplugin/14.png)

<div align=center>Gaussian</div><br>



## Filter 运行机制
## Filter operation mechanism

**note:**

note选项是行为控制标识,用于控制插件执行的流程,比如让框架进行类型兼容检测,如不满足自动中止。设定通道和序列支持设定,以及是否需要提供预览,roi等支持。
The note option is a behavior control identifier that controls the flow that the plug-in performs. For example, the framework performs type compatibility checks, and is automatic abortsed if they are not met. Set channel and sequence support settings, and whether to provide preview, roi and other support.

1. `all`:插件支持任意类型
1. `all`:The plug-in supports any type

2. `8-bit`:插件支持无符号8位
2. `8-bit`:The plug-in supports unsigned 8 bits

3. `16-bit`:插件支持无符号16位
3. `16-bit`:The plug-in supports unsigned 16 bits

4. `int`:插件支持32位,64位整数
4. `int`:The plug-in supports 32-bit, 64-bit integers

5. `rgb`:插件支持3通道24位彩色
5. `rgb`:The plug-in supports 3 channels, 24 - bit color

6. `float`:插件支持32位,64位浮点
6. `float`:The plug-in supports 32-bit, 64-bit floating point

------

7. `not_channel`:当处理多通道时,不要框架自动遍历通道(默认情况下会将每个通道依次处理)
7. `not_channel`:When working with multiple channels, we set to not allow the framework to automatically traverse channels (Each channel is processed in turn by default)

8. `not_slice`:当处理图像序列时,不要询问是否批量处理(默认情况会询问用户)
8. `not_slice`:When processing image sequences, we set to not ask if you want to batch them (Users are asked by default)

9. `req_roi`:是否必须有roi才能够处理
9. `req_roi`:Whether there must be roi to handle

---

10. `auto_snap`:是否需要框架在处理器对当前图像自动缓冲
10. `auto_snap`:Whether it is needed for the frame to automatically buffer the current image in the processor

11. `auto_msk`:是否自动支持ROI(必须配合auto_snap才生效,原理是用snap恢复ROI以外像素)
11. `auto_msk`:Whether roi is automatically supported or not(It must be combined with auto_snap to take effect, and the principle is to use snap to restore pixels other than roi)

12. `preview`:是否支持预览,调整参数实时查看结果
12. `preview`:Whether preview is supported to adjust parameters to see the results in real time

13. `2int`:是否在运算过程中将低于int32的数据转为int32再进行处理(例如避免8位的运算溢出)
13. `2int`:Whether to convert data lower than int32 to int32 for further processing (For example, to avoid 8-bit operation overflow)

14. `2float`:是否在运算过程中将低于float32的数据自动转为float32再进行处理(一些运算要求精度)
14. `2float`:Whether to automatically convert the data lower than float32 to float32 for further processing during processing (some operations require precision)

**para, view:** 参数字典,具体用法参阅start入门。
**para, view:** Parameter dictionary, see start for details.

**run:**

1. `ips`:图像封装类,通常在`filter`中不需要对其进行操作
2. `snap`:当`note`里加入`auto_snap`标识后,在`run`之前框架会将当前图像拷贝到`snap`(尽可能实现使用对snap进行处理,将结果赋值给img)
3. `img`:当前图像,我们将结果赋值给`img`,或`return`结果,由框架赋值给`img`,并完成界面刷新。
1. ` ips ` : image wrapper class. The ` filter ` don't need often to operate it.
2. ` snap ` : when joining the ` auto_snap ` logo in ` note `, framework will copy current image to ` snap ` before ` run ` ( As much as possible to use snap to deal with implementations, the results will be assigned to the img)
3. ` img ` : current image. We will assign the result to ` img `, or we ` return ` results. The framework assign result to ` img `, and complete refreshing the interface.

**load:**

`def load(self, ips)` 最先执行,如果`return`结果为`False`,插件将中止执行。默认返回`True`,如有必要,可以对其进行重载,进行一系列条件检验,如不满足,`IPy.alert`弹出提示,并返回`False`。
` def load (self, ips) ` are executed first. If result of the ` return ` is ` False `, plug-in will suspend execution. The default returns ` True `. If necessary, it can be overloaded with a series of condition inspection.If not met, ` IPy. alert ` will pop up prompts, and will return the ` False `.

**preview:**

`def preview(self, ips, para)` 在预览时执行,默认会调用`run`处理当前图像,如果有必要可以对其进行重载。
` def preview (self, ips, para) ` can be executed when selecting preview status. The default will call ` run ` to process current image. If necessary, it can be overloaded.