My data type changes to uint8 after if condition I want to keep it int16
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm running a for loop with an if condition. In this loop I apply conditions to an int16 image after reading it. However, for some reason the data type changes to uint8 which I don't want. I want to keep the data type the same (int16). Help!!!!
Here is the code I'm using:
%I want to keep data type the same!!
for TrialFrame=1:num_stackimages;
image=imread(fullFileName,TrialFrame); %Here the data type is int16
if Trials==1
SubVideoGREEN(:,:,TrialFrame)=image; %Here data type changes to uint8
else
TrialFrame2=TrialFrame+num_stackimages.*(Trials-1);
SubVideoGREEN(:,:,TrialFrame2)=image; %Here data type changes to uint8
end
end
7 comentarios
dpb
el 29 de Jun. de 2021
But that's not the variable complained over...it'll be a double unless it's been cast somewhere earlier...which, of course, without rest of code and without the data files it's pretty-much a guess as to why/what is happening...
Respuestas (1)
Jan
el 30 de Jun. de 2021
Editada: Jan
el 30 de Jun. de 2021
A simplification of your code:
SubVideoGREEN = zeros(H, W, F, 'int16');
for TrialFrame=1:num_stackimages;
TrialFrame = TrialFrame + num_stackimages * (Trials - 1);
SubVideoGREEN(:, :, TrialFrame) = ...
imread(fullFileName, TrialFrame);
end
There is no need to distinguish the case Trial==1 from the other frames, because the formula to get the TrialFrame replies the same value for both cases.
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!