包含BorderSize参数时的Blockproc错误 [英] Blockproc error when including BorderSize argument
问题描述
我正在Matlab在dct https:上进行练习: //www.mathworks.com/help/images/discrete-cosine-transform.html
I'm working on the exercise by Matlab on dct https://www.mathworks.com/help/images/discrete-cosine-transform.html
我运行了以下代码:
I = imread('cameraman.tif');
I = im2double(I);
imshow(I)
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct,'BorderSize',[4 4],'Trim',false) %modification made here
代码来自上面的链接,但是我包括了"BorderSize"标准,以允许块的重叠.运行代码后,出现错误提示:
The code was from the link above, but i included the 'BorderSize' criteria to allow for overlapping of the blocks. Upon running the code, i get the error saying:
Error using blockprocFunDispatcher
BLOCKPROC encountered an error while evaluating the user-supplied function handle,FUN.
Error in blockprocInMemory
[u1_output fun_nargout] = blockprocFunDispatcher(fun,block_struct,...
Error in blockproc
result_image = blockprocInMemory(source,fun,options);
什么可能是导致上述错误消息的问题?如果我删除'BorderSize',[4 4],'Trim',false ,它像链接中一样正常工作,但是我使用错误吗?
What could be the issue causing the error message above? If i remove 'BorderSize',[4 4], 'Trim',false it works as normal like in the link but am i using it wrongly?
推荐答案
您是否考虑到以下事实:指定了BorderSize后,在函数dct的定义中您的块大小会更大吗?您的函数将收到一个12x12的块,听起来像矩阵中的大小不匹配乘以T和T'.您是否需要将T的定义更改为:
Are you accounting for the fact that with BorderSize specified, your block size will be bigger in your definition of the function dct? Your function will receive a 12x12 block, sounds to me like a size mismatch in the matrix multiplies with T and T'. Do you need to change the definition of T to:
T = dctmx(12)
?
这篇关于包含BorderSize参数时的Blockproc错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!