Borrar filtros
Borrar filtros

matrix Dimension Must Agree

1 visualización (últimos 30 días)
Muhammad Ali Qadar
Muhammad Ali Qadar el 10 de Mzo. de 2013
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 comentarios
Walter Roberson
Walter Roberson el 10 de Mzo. de 2013
Which line is the problem appearing on?
Muhammad Ali Qadar
Muhammad Ali Qadar el 10 de Mzo. de 2013
Error using +
Matrix dimensions must agree.
Error in saltpepper (line 14)
t_pn=(im2double(t)+(p/2)/2);

Iniciar sesión para comentar.

Respuesta aceptada

Wayne King
Wayne King el 10 de Mzo. de 2013
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 comentarios
Muhammad Ali Qadar
Muhammad Ali Qadar el 10 de Mzo. de 2013
Worked !!!! Thanks a lot, can you Please Tell me how could you figure out this trick.
Wayne King
Wayne King el 10 de Mzo. de 2013
Glad it worked, not a trick, I think Walter's comment is instructive here.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by