Error while using blockproc. Matrix dimensions must agree.

2 views (last 30 days)
Hi,
I'm trying to use blockproc to compress a watermark that I want to embed. I'm using discrete cosine transform. I'm using blockproc for the first time, so I just copied the code off a youtube video to see how it works.
This is the code I'm using.
A=imread('C:\Users\hanuman\Documents\studies sheep\sem 7\FINAL YEAR PROJECT\project\house.jpg');
abc=imread('C:\Users\hanuman\Documents\studies sheep\sem 7\FINAL YEAR PROJECT\project\ABC watermark.jpg'); %reading the watermark
abc=imresize(abc, [96, 96]); %resizing the watermark to a number divisible by 8
f1= @(block_struct) dct2(block_struct.data);
f2= @(block_struct) idct2(block_struct.data);
J=blockproc(abc, [8 8], f1);
depth= find(abs(J)<150);
J(depth)= zeros(size(depth));
K= blockproc(J, [8 8], f2)/255;
This is the error matlab is showing:
BLOCKPROC encountered an error while evaluating the user-supplied function handle, FUN.
The cause of the error was:
Matrix dimensions must agree.
Error in dct (line 76)
b = W .* fft(y);
Error in dct2 (line 49)
b = dct(dct(arg1).').';
Error in Trial2>@(block_struct)dct2(block_struct.data)
Error in blockprocFunDispatcher (line 13)
output_block = fun(block_struct);
Error in blockprocInMemory (line 80)
[ul_output fun_nargout] = blockprocFunDispatcher(fun,block_struct,...
Error in blockproc (line 243)
result_image = blockprocInMemory(source,fun,options);
Error in Trial2 (line 8)
J=blockproc(abc, [8 8], f1);
If you know where I'm going wrong, please help.
Thank you for your time!

Accepted Answer

Matt J
Matt J on 13 Nov 2019
Edited: Matt J on 13 Nov 2019
Matrix dimensions must agree.
Error in dct (line 76)
b = W .* fft(y);
It would appear that W and y are not the same size.
  8 Comments
sripradha iyengar
sripradha iyengar on 13 Nov 2019
Edited: sripradha iyengar on 13 Nov 2019
ooh! Did come across that before... didn't know that it was more efficient.. Thank you for all the useful tips!:) :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!