plz help me out with this error..matrix dimension mismatch

part of my code is
img1=imread('img.jpg'); [m n]=size(img1); imnoise=img1+64*randn(m,n);
its giving an error like this
??? Error using ==> plus Matrix dimensions must agree.
Error in ==> prog4c at 6 imnoise = img1 + 64*randn([m,n]);
thanqq

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 2 月 28 日

0 投票

IMREAD usually returns a 3-D matrix, but you are collapsing the size to a 2-D by using:
[m n]=size(img1);
Try:
[m n q]=size(img1);
imnoise=img1+64*randn(m,n,q);

1 件のコメント

Rajesh Kumar
Rajesh Kumar 2012 年 3 月 1 日
my input is color img..so its in 3D..i converted to gray and got the output...thanq

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

カテゴリ

ヘルプ センター および File ExchangeSparse Matrices についてさらに検索

質問済み:

2012 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by