arrays - MATLAB - Element-wise matrix multiplication using two different sizes matrices -
i element-wise matrix multiplication using following 2x2x3 matrix in matlab
>> filter_1 filter_1(:,:,1) = 0 1 0 0 filter_1(:,:,2) = 1 0 0 1 filter_1(:,:,3) = 0 0 1 0
this matrix turn out 0 elements in matrix dimensions if used in element-wise multiplication. example, given 2x2x3 matrix:
>> frames_original{1} ans(:,:,1) = 92 87 93 93 ans(:,:,2) = 69 66 72 71 ans(:,:,3) = 42 40 40 43
if element-wise matrix multiplication, let values remain in resulting matrix, others turn out zero:
>> filtered=double(frames_original{1}).*filter_1 filtered(:,:,1) = 0 87 0 0 filtered(:,:,2) = 69 0 0 71 filtered(:,:,3) = 0 0 40 0
however, works if both matrices of same size (2x2x3). now, suppose have big matrix, 1500x1500x3 matrix. how 'slide' 2x2x3 window performing element-wise multiplication dealing matrix borders accordingly? if using n-d convolution, doesn't work, matlab deals operation even-dimensional-window convolution, , want element-wise multiplication.
is there way element-wise matrix multiplication using 1 big matrix , smaller in matlab?
edit: solution element wise multiplication of matrices of differing dimensions doesn't work me because involves different element-wise multiplication , requires reshaping, don't want.
suppose frames_original , filter_1 differ @ first 2 dimensions, , can duplicate filter_1 match size of frames_original.
m1 = size(frames_original, 1) / size(filter_1, 1); m2 = size(frames_original, 2) / size(filter_1, 2); filter_2 = repmat(filter_1, [m1 m2 1]; % error if m1 m2 not integer filtered = double(frames_original{1}) .* filter_2;
wiki
Comments
Post a Comment