Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Convolution ('Conv') in MATLAB

  1. Oct 27, 2007 #1
    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:

    Code (Text):

    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: Oct 27, 2007
  2. jcsd
  3. Oct 27, 2007 #2
    I figured out what the problem was; this can be closed/deleted.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Convolution ('Conv') in MATLAB
  1. MATLAB histogram (Replies: 3)

Loading...