Skip to content

Commit

Permalink
新增命令【图片锐化】
Browse files Browse the repository at this point in the history
  • Loading branch information
super1207 committed Nov 29, 2024
1 parent 798676b commit afa6fe9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/detailref/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,14 @@ bbb=2

图片模糊使用高斯模糊,<font color="red">sigma</font>为高斯函数中的sigma参数,必须大于0(否则原样输出),越大越模糊。

### 图片锐化


【图片锐化@<font color="red">图片字节集</font>@<font color="red">sigma</font>@<font color="red">threshold</font>】

图片锐化使用[Unsharp masking](https://en.wikipedia.org/wiki/Unsharp_masking),<font color="red">sigma</font>须大于0,越大越锐化,比如10。<font color="red">threshold</font>默认为0,可以省略。



### GIF合成

Expand Down
17 changes: 17 additions & 0 deletions src/redlang/exfun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,23 @@ pub fn init_ex_fun_map() {
return Ok(Some(ret));
});

add_fun(vec!["图片锐化","图像锐化"],|self_t,params|{
let text1 = self_t.get_param(params, 0)?;
let (_,img) = RedLang::parse_img_bin(&mut self_t.bin_pool,&text1)?;
let sigma = self_t.get_param(params, 1)?.parse::<f32>()?;
let threshold_text = self_t.get_param(params, 2)?;
let threshold;
if threshold_text == "" {
threshold = 0;
}else{
threshold = threshold_text.parse::<i32>()?;
}
let img_out;
img_out = image::imageops::unsharpen(&img,sigma,threshold);
let ret = self_t.build_img_bin((ImageFormat::Png, img_out));
return Ok(Some(ret));
});

add_fun(vec!["图片上叠加","图像上叠加"],|self_t,params|{
let text1 = self_t.get_param(params, 0)?;
let text2 = self_t.get_param(params, 1)?;
Expand Down

0 comments on commit afa6fe9

Please sign in to comment.