I am trying to use blockproc (A,[8 8 ],dct2) to create a block of 8X8 from A image of 600X800 it does not works as they are telling me that dct2 is not a handle function . what is the exact argument I have to use instead of dct2?
6 次查看(过去 30 天)
显示 更早的评论
A = imread('C:\lesloges.png'); B= rgb2gray(A); B=double(B)/255.0;
C= blockproc(B,[8 8],dct2);
Error using dct2 (line 45) Not enough input arguments.
Error in essaidecoupagebloc88 (line 11) C= blockproc(B,[8 8],dct2)
2 个评论
Geoff Hayes
2014-5-29
According to http://www.mathworks.com/help/images/ref/blockproc.html#inputarg_fun, a function handle is required. Try putting an ampersand in front of dct2:
C= blockproc(B,[8 8],@dct2);
Note that if I do
y = @dct2;
then class(y) returns function_handle.
回答(2 个)
Geoff Hayes
2014-5-30
The documentation for the blockproc function (see http://www.mathworks.com/help/images/ref/blockproc.html for details) indicates that the function handle must be to a function that accepts a block struct as input and returns a matrix, vector, or scalar. Your function, dct2, accepts a matrix only, not a structure. So you will have to do something like the example from the blockproc link:
% their example
fun = @(block_struct) imresize(block_struct.data,0.15);
% your code
fun = @(block_struct) dct2(block_struct.data);
J = blockproc(I,[8 8],fun);
Try the above and see if it helps.
Meshooo
2014-9-24
Hi Lu,
Check the following url, it shows a very good example for block processing.
Hope it helps you.
Meshoo
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!