ThresholdTypes.Tozero注解
时间: 2023-06-21 21:20:22 浏览: 46
ThresholdTypes.Tozero 是 OpenCV 中的一个阈值类型,表示将小于阈值的像素值置为 0,大于阈值的像素值不变。在 OpenCvSharp 中,ThresholdTypes.Tozero 是一个枚举值,可以通过调用 Mat.Threshold 方法来实现。
Mat.Threshold 方法的定义如下:
```csharp
public static void Threshold(InputArray src, OutputArray dst, double thresh, double maxval, ThresholdTypes type);
```
其中,输入参数 src 表示输入图像,输出参数 dst 表示输出图像,thresh 表示阈值,maxval 表示最大像素值,type 表示阈值类型。
当 type 参数设置为 ThresholdTypes.Tozero 时,Mat.Threshold 方法将对输入图像进行阈值化处理,将小于阈值的像素值置为 0,大于阈值的像素值不变,然后将结果保存到输出图像 dst 中。
需要注意的是,Mat.Threshold 方法支持的阈值类型还包括二进制阈值(ThresholdTypes.Binary)、反二进制阈值(ThresholdTypes.BinaryInv)、截断阈值(ThresholdTypes.Trunc)、取零阈值反转(ThresholdTypes.TozeroInv)。每种阈值类型的具体作用可以参考 OpenCV 官方文档。
相关问题
OpenCvSharp ThresholdTypes.Trunc 注解
ThresholdTypes.Trunc 是 OpenCV 中的一个阈值类型,表示将大于阈值的像素值截断为阈值,小于阈值的像素值不变。在 OpenCvSharp 中,ThresholdTypes.Trunc 是一个枚举值,可以通过调用 Mat.Threshold 方法来实现。
Mat.Threshold 方法的定义如下:
```csharp
public static void Threshold(InputArray src, OutputArray dst, double thresh, double maxval, ThresholdTypes type);
```
其中,输入参数 src 表示输入图像,输出参数 dst 表示输出图像,thresh 表示阈值,maxval 表示最大像素值,type 表示阈值类型。
当 type 参数设置为 ThresholdTypes.Trunc 时,Mat.Threshold 方法将对输入图像进行阈值化处理,将大于阈值的像素值截断为阈值,小于阈值的像素值不变,然后将结果保存到输出图像 dst 中。
需要注意的是,Mat.Threshold 方法支持的阈值类型还包括二进制阈值(ThresholdTypes.Binary)、反二进制阈值(ThresholdTypes.BinaryInv)、截断阈值(ThresholdTypes.Trunc)、取零阈值(ThresholdTypes.Tozero)和反取零阈值(ThresholdTypes.TozeroInv)。每种阈值类型的具体作用可以参考 OpenCV 官方文档。
@EqualsAndHashCode.Include 注解作用
@EqualsAndHashCode.Include 注解是在 Java 中用于指定需要包含在 equals() 和 hashCode() 方法中的字段。通常情况下,equals() 方法会比较对象的所有字段来判断它们是否相等,而 hashCode() 方法则会使用所有字段来计算对象的哈希码。然而,在某些情况下,我们可能只想比较或计算部分字段的值。
使用 @EqualsAndHashCode.Include 注解可以指定哪些字段需要包含在 equals() 和 hashCode() 方法中。当我们在类上添加该注解时,会自动为被注解的字段生成相应的 equals() 和 hashCode() 方法,而不包含该注解的字段则不会被包含在这两个方法中。
例如:
```java@Getter@Setter@EqualsAndHashCode.Includepublic class Person {
private String name;
private int age;
// ...
}
```
在上面的例子中,@EqualsAndHashCode.Include 注解被添加在 Person 类上,并且会应用于 name 和 age 字段。这意味着在生成 equals() 和 hashCode() 方法时,只会考虑这两个字段的值。其他没有被注解的字段将不会影响这两个方法的实现。
请注意,如果不使用 @EqualsAndHashCode.Include 注解,默认情况下,Lombok 的 @EqualsAndHashCode 注解会将所有字段包含在 equals() 和 hashCode() 方法中。因此,使用 @EqualsAndHashCode.Include 注解可以更细粒度地控制方法的生成。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)