現在の画像のピクセル​ごとの輝度から、ひと​つ前の画像のピクセル​ごとの輝度を引き算す​る方法

1 view (last 30 days)
suzuka iwaki
suzuka iwaki on 1 Feb 2024
Commented: Atsushi Ueno on 3 Feb 2024
jpegFiles = dir('*.jpg');
numfiles = ; % フォルダ内のファイルの数
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = imread(jpegFiles(k).name);
RGB = imread(jpegFiles(k).name);
T{k} = rgb2gray(RGB);
end
T{1}
上のコードで画像のピクセルごとの輝度を求めているのですが、求めた輝度から、ひとつ前の画像のピクセルごとの輝度を引き算するコードを教えていただきたいです。

Answers (1)

Atsushi Ueno
Atsushi Ueno on 3 Feb 2024
[filepath,name,ext] = fileparts(which('office_1.jpg'));
jpegFiles = dir([filepath,filesep,'office_*.jpg']);
numfiles = size(jpegFiles, 1); % フォルダ内のファイルの数
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = imread(jpegFiles(k).name);
RGB = imread(jpegFiles(k).name);
T{k} = rgb2gray(RGB);
if k > 1
diff = T{k} - T{k-1}; % ひとつ前の画像のピクセルごとの輝度を引き算する
end
end
  1 Comment
Atsushi Ueno
Atsushi Ueno on 3 Feb 2024
引き算の対象画像サイズが一致する必要があります。
一致しない場合は、合致しない面積の部分の扱い方を決める必要があります。

Sign in to comment.

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!