I want column matrix in for loop
Afficher commentaires plus anciens
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
Réponses (1)
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 commentaires
HEMRAJ PATEL
le 30 Nov 2021
DGM
le 30 Nov 2021
You'll need to explain how it doesn't work or how it doesn't meet your requirements.
yanqi liu
le 1 Déc 2021
yes,sir,may be use
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));
R = imsubtract(I2,I1);
R = R(xrange,yrange);
c(k,:) = I2(:)-I1(:);
end
DGM
le 1 Déc 2021
That's obviously not going to work if I2,I1 don't exist.
If the goal is to avoid the issues caused by data scaling, I usually recommend to simply use im2double(). I guess I didn't bother.
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 = im2double(image1(xrange,yrange));
I2 = im2double(image2(xrange,yrange));
c(k,:) = I2(:)-I1(:);
end
or you could use imsubtract()
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));
D = imsubtract(image2(xrange,yrange),image1(xrange,yrange));
c(k,:) = D(:);
end
If the image classes differ, that will at least cast and scale them so that they're compatible, but the output scale and class will vary with whatever the inputs are. You could cast D with im2double() or the like, but it seems unnecessary when the output class can be asserted to begin with.
That said, OP hasn't mentioned what the problem actually is.
HEMRAJ PATEL
le 1 Déc 2021
Catégories
En savoir plus sur Image Filtering dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!