Is their any substitue of blockproc for computing dct and quantizing the image

2 views (last 30 days)
I am trying to do following
>> x = imread('cat.png'); >> [xm, xn] = size(x); >> x = double(x) - 128; >> T = dctmtx(8); >> dct = @(block_struct) T * block_struct.data * T'; >> D = blockproc(x,[8 8],dct);
Function BLOCKPROC encountered an error while evaluating the user supplied function handle, FUN.
The cause of the error was:
Error using * Inputs must be 2-D, or at least one input must be scalar. To compute elementwise TIMES, use TIMES (.*) instead.
Error in @(block_struct)T*block_struct.data*T'
Error in blockprocFunDispatcher (line 14) output_block = fun(block_struct);
Error in blockprocInMemory (line 81) [ul_output fun_nargout] = blockprocFunDispatcher(fun,block_struct,...
Error in blockproc (line 234) result_image = blockprocInMemory(source,fun,options);

Answers (1)

Walter Roberson
Walter Roberson on 25 Dec 2012
It appears that you have assumed that imread() is going to return a 2D array. Suppose, though, it is an RGB image: then it would return a 3D array. Is dct even defined for 3D arrays? Perhaps you will need to process individual color planes.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!