I want column matrix in for loop

5 views (last 30 days)
HEMRAJ PATEL
HEMRAJ PATEL on 30 Nov 2021
Commented: HEMRAJ PATEL on 1 Dec 2021
I want to create a matrix where the R (subtracted) matrix is stored in C matrix such that all 9 R(i,j) elements produced from 10 images get stored in first column of matrix c, then next R(i,j) be stored in 2nd column of matrix c and so on.
Here x is row no.
and y is column no.
use whatever image you like with 400X400 pixels
n=10
for x=11:1:13
for y=11:1:13
for i=1:1:9
for k =1:1:(n-1)
image1 = double(imread(sprintf('image_%.4d.jpg',k)));
I1=image1(1:400,1:400);
image2 = double(imread(sprintf('image_%.4d.tiff',k+1)));
I2=image2(1:400,1:400);
R= imsubtract(I2,I1);
c(k,i)=R(x,y);
end
end
end
end

Answers (1)

DGM
DGM on 30 Nov 2021
Edited: DGM on 30 Nov 2021
I'm not sure, but this might be close to what you want.
n=10
xrange = 11:13;
yrange = 11:13;
for k = 1:(n-1)
image1 = imread(sprintf('image_%.4d.jpg',k));
image2 = imread(sprintf('image_%.4d.tiff',k+1));
I1 = double(image1(xrange,yrange));
I2 = double(image2(xrange,yrange));
c(k,:) = I2(:)-I1(:);
end
  5 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!