Error while using blockproc. Matrix dimensions must agree.

2 ビュー (過去 30 日間)
sripradha iyengar
sripradha iyengar 2019 年 11 月 13 日
コメント済み: sripradha iyengar 2019 年 11 月 13 日
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!

採用された回答

Matt J
Matt J 2019 年 11 月 13 日
編集済み: Matt J 2019 年 11 月 13 日
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 件のコメント
sripradha iyengar
sripradha iyengar 2019 年 11 月 13 日
編集済み: sripradha iyengar 2019 年 11 月 13 日
ooh! Did come across that before... didn't know that it was more efficient.. Thank you for all the useful tips!:) :)
sripradha iyengar
sripradha iyengar 2019 年 11 月 13 日
I meant mat2cell, this one is new!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by