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?
Show older comments
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 Comments
Geoff Hayes
on 29 May 2014
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.
yaowu groshenry
on 30 May 2014
Answers (2)
Geoff Hayes
on 30 May 2014
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.
1 Comment
Lu
on 24 Sep 2014
Errors:
Meshooo
on 24 Sep 2014
0 votes
Hi Lu,
Check the following url, it shows a very good example for block processing.
Hope it helps you.
Meshoo
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!