plz help me out with this error..matrix dimension mismatch
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Kaustubha Govind
on 28 Feb 2012
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);
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!