現在の画像のピクセルごとの輝度から、ひとつ前の画像のピクセルごとの輝度を引き算する方法
Show older comments
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
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
on 3 Feb 2024
引き算の対象画像サイズが一致する必要があります。
一致しない場合は、合致しない面積の部分の扱い方を決める必要があります。
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!