필터 지우기
필터 지우기

why isn't image changing when it is supposed to?

조회 수: 1 (최근 30일)
mark palmer
mark palmer 2023년 2월 26일
답변: mark palmer 2023년 2월 28일
THis one has me stumped for two days straight. It seems like it should be the easiest thing in the world, but there's something I'm just not getting.
I want the image to change to the next image every time bb = 3, or fstep/2, and stay on that image otherwise. There will be other images coming in at different places, so I can't just adjust the starting point, it has to change at bb=fstep/2 exactly. Nothing I code will do this, it keeps changing only at bb=1 instead. I'm mystified, can anybody see what's wrong and can suggest a change with as little modification to the original code as possible?
clear all
clf
fpath1 = '/Users/owner/Documents/MATLAB1/';
addpath(fpath1);
pI1 = 1 + [0, 1, 2];
pIsiz = size(pI1,2);
IB = {'T5 01.jpg'; 'T5 02.jpg'; 'T5 03.jpg'};
fI1B = {IB{pI1(1:pIsiz)}};
fstep = 3; % FRAME STEPS BETWEEN EACH IMAGE ----------------
bbm = [(fstep/2)+1:fstep 1:fstep/2];
fstep = fstep * 2;
cc = 1;
for aa = 1:3
astr = num2str2023(aa); % FILE NAME INCREMENT VALUE
I2 = imread(fI1B{aa});
for bb = 1:fstep
[aa bb cc]
if mod(cc,fstep) == fstep/2
I2 = imread(fI1B{aa});
fI1B{aa}
end
astr = num2str2023(aa); % FILE NAME INCREMENT VALUE
bstr = num2str2023(bb);
imf12 = [fpath1,'MTEST ' astr,' ', bstr, ' 2023.tif'];
imwrite(I2, imf12, 'tif', 'Resolution', 720);
cc = cc + 1;
end
end

답변 (2개)

Walter Roberson
Walter Roberson 2023년 2월 27일
cc starts at 1.
fstep is 3.
mod() of an integer by 3 is going to be an integer.
You compare that integer to fstep/2 which is 3/2 which is a non-integer.
Therefore the mod() can only come true if at some point you increment c by a non-integer. But you never do, you only increment it by 1.
  댓글 수: 1
mark palmer
mark palmer 2023년 2월 27일
thanks for your response!
fstep is 6 (fstep * 2) by the time it reaches the loop. bbm can be ignored

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


mark palmer
mark palmer 2023년 2월 28일
I figured out the issue, thanks.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by