Reputation: 4728
I can save a .png image as pic = imread(image_name)
and I can treat it as a matrix including the size so that I can retrieve [nrows, ncols, ~] = size(pic)
. I can then easily show this image with imshow(pic)
.
However, if I create my own matrix with test = zeros(nrows, ncols, 3)
and try to copy over the image with test(:, :, :) = pic
and try to use imshow(test)
it doesn't work. I can compare test
and pic
element by element and they are the same, but I can't subtract the two or I get an error of
Error using -
Integers can only be combined with integers of the same class, or scalar doubles.
How can I create a matrix and assign pixels from an image to it and still treat the matrix as an image? The reason I am trying to do this is that I have many pictures I am trying to combine into one larger picture, so I need to create a large matrix beforehand, then copy pixels from each seperate image into the larger matrix, but this larger matrix is no longer treated as an image when I use imshow
or imwrite
.
Upvotes: 0
Views: 271