WHEN I AM RUNNING THIS CODE I AM GETTING FOLLOWING ERROR

3 ビュー (過去 30 日間)
sabitri
sabitri 2022 年 7 月 20 日
編集済み: sabitri 2022 年 7 月 20 日
function [p,s] = perdecomp(u)
[ny,nx] = size(u);
u = double(u);
X = 1:nx;
Y = 1:ny;
v = zeros(ny,nx);
v(1,X) = u(1,X)-u(ny,X);
v(ny,X) = -v(1,X);
v(Y,1 ) = v(Y,1 )+u(Y,1)-u(Y,nx);
v(Y,nx) = v(Y,nx)-u(Y,1)+u(Y,nx);
fx = repmat(cos(2.*pi*(X -1)/nx),ny,1);
fy = repmat(cos(2.*pi*(Y'-1)/ny),1,nx);
fx(1,1)=0.; % avoid division by 0 in the line below
s = real(ifft2(fft2(v)*0.5./(2.-fx-fy)));
p = u-s;
Arrays have incompatible sizes for this operation.
Error in perdecomp (line 17)
p = u-s;

採用された回答

VBBV
VBBV 2022 年 7 月 20 日
u = rand(1,5) % assume a matrix values
u = 1×5
0.1621 0.3146 0.5520 0.9985 0.1474
[p,s]= perdecomp(u) % call the function giving input matrix u
p = 1×5
0.1562 0.3116 0.5520 1.0015 0.1532
s = 1×5
0.0059 0.0029 0.0000 -0.0029 -0.0059
function [p,s] = perdecomp(u)
[ny,nx] = size(u);
u = double(u);
X = 1:nx;
Y = 1:ny;
v = zeros(ny,nx);
v(1,X) = u(1,X)-u(ny,X);
v(ny,X) = -v(1,X);
v(Y,1 ) = v(Y,1 )+u(Y,1)-u(Y,nx);
v(Y,nx) = v(Y,nx)-u(Y,1)+u(Y,nx);
fx = repmat(cos(2.*pi*(X -1)/nx),ny,1);
fy = repmat(cos(2.*pi*(Y'-1)/ny),1,nx);
fx(1,1)=0.; % avoid division by 0 in the line below
s = real(ifft2(fft2(v)*0.5./(2.-fx-fy)));
p = u-s;
end
Give input vector when calling function perdecomp
  1 件のコメント
sabitri
sabitri 2022 年 7 月 20 日
編集済み: sabitri 2022 年 7 月 20 日
Sir, i have to perform this decomsition on an jpg image. when i am writing u=imread('u.jpg') i am getting a long matrix..How can i solve this? here u is an jpg file saved in the folder. @VBBV

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEncryption / Cryptography についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by