title: Is it possible to multiply a 3x3 matrix (a color transformation) with a rank 3 tensor/3D matrix (a color image)?
body: <p>When images are read in, they are converted into matrices/tensors of dimension (x,y,3) where the last one is for the R, G, B channels. </p>
  
  <p>I am looking to apply a colorspace conversion, so that's a 3x3 matrix that I want to apply to each pixel. So what I'm sort of looking to do here is a "component wise" matrix-vector multiply. </p>
  
  <p>Can this be done with matlab/octave? I'm using octave but it seems like if there's a way with matlab I should have a fighting chance with octave. </p>
  
  <p>I'm just getting something like this: </p>
  
  <pre><code>octave:15&gt; B
  B =
  
     0.9465229   0.2946927  -0.1313419
    -0.1179179   0.9929960   0.0073716
     0.0923046  -0.0464579   0.9946464
  
  octave:16&gt; B * Y
  error: invalid conversion of NDArray to Matrix
  </code></pre>
  
  <p>I guess I just gotta do a nested for loop manually. But even when I try this: </p>
  
  <pre><code>Blena = lena; %// copy the structure -- here lena is a rgb image of type double
  for i=1:rows(lena)
    for j=1:columns(lena)
      Blena(i,j) = B * lena(i,j,:);
    endfor
  endfor
  </code></pre>
  
  <p><code>lena(i,j,:)</code> is still an NDArray. </p>