我想用图像块的快速处理方法将一幅图像求中值,可是总有错误

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:59:14
程序代码是

i=imread('whitegray.jpg');
i1=colfilt(i,[3,5],'silding',fun);
fun=inline('median(x)');
figure(1),imshow(i1,[]);

图像时450×600的

错误是

??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> colfilt at 186
b(i*mb+brows,j*nb+bcols) = ...
谁知道 请给我解答,谢谢啦

我运行了一下,没有出现你这个reshape的错误,出现的是
Undefined function or variable "fun".
Error in ==> try2 at 4
i1=colfilt(i,[3,5],'silding',fun);

改了一下顺序,把function的定义放到前面
fun=inline('median(x)');
i1=colfilt(i,[3,5],'silding',fun);
在我这里运行是没有问题的。

PS:最简单的就是
i1=colfilt(i,[3,5],'silding',@median);