what is wrong with the blockproc function in my code?
Show older comments
I am trying to write the function 'replace' that accesses every block in the image, keeps the first 2000 cooefficient and sets the rest of them to zero. but every time i do that i find this error message:
Error using blockproc>parse_inputs (line 997)
Invalid block function. BLOCKPROC expects the user function, FUN, to be a valid function handle.
Error in blockproc (line 219)
[source,fun,options] = parse_inputs(source,block_size,fun,varargin{:});
Error in blk2 (line 6)
J3 = blockproc(I3,[8 8],'dct2',f);
here is the function f code:
function features = replace(block)
for( i = 2000:length(block.data) )
% set each element to 0
block.data(i) = 0
end

%and the DCT and blockproc code:
I3 = imread('process/13.jpg');
figure;
imshow(I3);
f = @(block)replace(block.data);
J3 = blockproc(I3,[8 8],'dct2',f);
figure
imshow(J3);
imshow(log(abs(J3)),[]), colormap(jet), colorbar
J3(abs(J3) < 5) = 0;
%B=J;
%B(1:1) = 0;
[M N]=size(J3);
fun3=zigzag(J3);
in4=izigzag(fun3,M,N);
f = @(block)replace(block.data);
J22 = blockproc(in4,[8 8],'idct2',f);
figure
imshow(J22,[0 255]);
figure
imshow(log(abs(J22)),[]), colormap(jet), colorbar
1 Comment
Hadeer tawfik
on 20 Sep 2016
Accepted Answer
More Answers (0)
Categories
Find more on Blocked Images 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!