We want to run our filter bank on an image by convolving each filter in the bank with the image and concatenating all the responses into a vector for each pixel. Using the imfilter command in a loop to do this. Since color images have 3 channels, we are going to have a total of 3F filter responses per pixel if the filter bank is of size F . N Then output the result as a 3F channel image
final = [];
for i = 1: length(filterBank)
x = imfilter(img, cell2mat(filterBank(i)));
imshow(x);
final(i)= [x]
end
where :
filterBank is a 20X1 cell ; filterBank(i) is 5X5 double
img is a 230X307X3 uint8
final is just []
this gives an error Subscripted assignment dimension mismatch.
Then I tried :
final(1:1:1) = x
this gives an error : In an assignment A(:) = B, the number of elements in A and B must be the same.
I'm a matlab noob but basically want to save all the 3d matrices result on applying each filter to a single array then apply a montage command
You're trying to set a single element (
final(i)
) to the value of a matrix. Use cell arrays instead.Alternatively you could use a 4D matrix (3D for
x
, 1D for loop variable),