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!