cant add matrices of same dimensions

5 vues (au cours des 30 derniers jours)
Terry McGinnis
Terry McGinnis le 12 Oct 2015
Commenté : Terry McGinnis le 12 Oct 2015
im trying to add an image to a matrix of ones for which i have used the following code:
c=imread('C:\Users\Richik\Desktop\ima.png');
[x,y]=size(c)
m=ones(x,y);
g=m+c;
but even when the matrix dimensions are same,im getting this error:
??? Error using ==> plus
Matrix dimensions must agree.
i cant figure out why this is happening.....

Réponse acceptée

Walter Roberson
Walter Roberson le 12 Oct 2015
Chances are that your PNG image is an RGB image and so is 3 dimensional. You should look at
s = size(c)
[x,y] = size(c)
and I think you will find that y is not equal to s(2). Read the documentation for size() to understand why not.
  4 commentaires
Walter Roberson
Walter Roberson le 12 Oct 2015
A change of 1/256 in the brightness of an image is not necessarily going to be very noticeable, especially if you have not used a full 256 entry colormap
colormap(gray(256))
Terry McGinnis
Terry McGinnis le 12 Oct 2015
thank u

Connectez-vous pour commenter.

Plus de réponses (1)

Eng. Fredius Magige
Eng. Fredius Magige le 12 Oct 2015
Hi It has to follow its rule, and might be g=[m,c];
  1 commentaire
Walter Roberson
Walter Roberson le 12 Oct 2015
That would, if it worked, append c after m, not add 1 to each element of c.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by