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?
4 ビュー (過去 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!