- #1
mushiman
- 10
- 0
I have a problem/error that I believe is very simple, but I am unable to determine what the issue is nonetheless.
I am trying to convolute an image with an impulse response (IE, h = [1 2 3]), but I get incessant errors and I am unsure as to why. My code is:
I get the error "? Subscripted assignment dimension mismatch.", or alternatively, MATLAB returns "? Error using ==> conv, A and B must be vectors." if I attempt to zero-pad my impulse response (h), then insert my matrix values of 1, 2, and 3.
I'm sure that I am missing something very simple here, but I do not know what it is. At the moment, I am running this code in the terminal, although I don't believe that this is the cause of the problem.
Thank you to anyone who helps -- I'm banging my head against the desk.
Edit: Just a quick note... apparently I forgot to convert to grayscale, and for that reason this image was a 3-dimensional matrix, which doesn't fly in this situation. However, I am still unsure as to how to get it formatted properly, as rgb2gray does not give me the output that I was looking for (it converts the image into a bright red color).
I am trying to convolute an image with an impulse response (IE, h = [1 2 3]), but I get incessant errors and I am unsure as to why. My code is:
Code:
A = double(imread('image.jpg'));
B = zeros(514);
h = [1 2 3];
for k = 1:512
B(k,:) = conv[A(k,:),h];
I get the error "? Subscripted assignment dimension mismatch.", or alternatively, MATLAB returns "? Error using ==> conv, A and B must be vectors." if I attempt to zero-pad my impulse response (h), then insert my matrix values of 1, 2, and 3.
I'm sure that I am missing something very simple here, but I do not know what it is. At the moment, I am running this code in the terminal, although I don't believe that this is the cause of the problem.
Thank you to anyone who helps -- I'm banging my head against the desk.
Edit: Just a quick note... apparently I forgot to convert to grayscale, and for that reason this image was a 3-dimensional matrix, which doesn't fly in this situation. However, I am still unsure as to how to get it formatted properly, as rgb2gray does not give me the output that I was looking for (it converts the image into a bright red color).
Last edited: