matrix Dimension Must Agree

2 ビュー (過去 30 日間)
Muhammad Ali Qadar
Muhammad Ali Qadar 2013 年 3 月 10 日
please some suggest me Where I am going wrong, I want to add periodic noise in my Image
if true
tw=imread('twins.tif');
t=rgb2gray(tw);
%Creating Periodic noise
s=size(t);
[x,y]=meshgrid(1:s(1),1:s(2));
p=(sin(x/3+y/5)+1);
t_pn=(im2double(t)+(p/2)/2);
imshow(t),figure,imshow(t_pn);
% code
end
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 3 月 10 日
Which line is the problem appearing on?
Muhammad Ali Qadar
Muhammad Ali Qadar 2013 年 3 月 10 日
Error using +
Matrix dimensions must agree.
Error in saltpepper (line 14)
t_pn=(im2double(t)+(p/2)/2);

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

採用された回答

Wayne King
Wayne King 2013 年 3 月 10 日
Without more information about your image size, which you don't provide, it's hard to say, but try transposing the p matrix as I've done below:
tw=imread('twins.tif');
t=rgb2gray(tw);
%Creating Periodic noise
s=size(t);
[x,y]=meshgrid(1:s(1),1:s(2));
p=(sin(x/3+y/5)+1)';
t_pn=(im2double(t)+(p/2)/2);
  3 件のコメント
Muhammad Ali Qadar
Muhammad Ali Qadar 2013 年 3 月 10 日
Worked !!!! Thanks a lot, can you Please Tell me how could you figure out this trick.
Wayne King
Wayne King 2013 年 3 月 10 日
Glad it worked, not a trick, I think Walter's comment is instructive here.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by