I want to creat the loop of background substraction.

조회 수: 1 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 7월 16일
댓글: muhammad choudhry 2020년 7월 17일
Hi,
I am using the simple code line to substract one picture from another as given below.
k=image1-image2;
then I will need to subtract 10 more pictures from image 1 to see the difference.
for example:
k=image1-image2;
k1=image1-image3;
k2=image1-image4;
Is there a way that I can make a loop in which all the Images (2,3,4,5,6,7....) I want will be subtracted from image1.

채택된 답변

David Hill
David Hill 2020년 7월 16일
Place all images into a cell array.
for m=2:length(image)
k{m-1}=image{1}-image{m};
end
  댓글 수: 3
David Hill
David Hill 2020년 7월 17일
First you need to read all the images into the cell array.
for m=1:10
image{m}=imread(sprintf('image%d.jpg',m));%assuming the names of your files are image1.jpg ...
end
for m=2:length(image)
k{m-1}=image{1}-image{m};
end
muhammad choudhry
muhammad choudhry 2020년 7월 17일
Great that works, and if I want to save them images into a folder what should I do?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by