To workaround the problem - I tried the just discovered new option '+Fn' to extract the pixel data in parts. The manpage writes: 'use absolute frame number for filenames'. If I want to extract only 2 or 800 frames, the option always adds 20 frames, e.g.:
# How many frames per run should be extracted
FRAMECOUNT=500
# how man full runs with $FRAMECOUNT are needed
FULLRUNS=$(echo "${NumberOfFrames}/${FRAMECOUNT}" | bc)
# how many frames have to be extracted during the last run
RESTFRAMES=$(echo "${NumberOfFrames}%${FRAMECOUNT}" | bc)
# A while loop calls dcmj2pnm multiple times ($FULLRUNS) with an amount of $FRAMECOUNT frames
FULLRUNCOUNT=1
STARTCOUNT=1
while [ ${FULLRUNCOUNT} -le ${FULLRUNS} ]; do
${BINDIR}/dcmj2pnm --frame-range ${STARTCOUNT} ${FRAMECOUNT} ${dcmj2pnm_us_opts[@]} ${FILE} ${FRAMEDIR}/mf || error "'${FILE}' failed"
STARTCOUNT=$[STARTCOUNT +${FRAMECOUNT}]
FULLRUNCOUNT=$[FULLRUNCOUNT +1]
done
# then the remainding frames will be processed ... if the $NumberOfFrames is lower than $FRAMECOUNT, this run of dcmj2pnm is executed only ...
if [ ${RESTFRAMES} -gt 0 ]; then
${BINDIR}/dcmj2pnm --frame-range ${STARTCOUNT} ${RESTFRAMES} ${dcmj2pnm_us_opts[@]} ${FILE} ${FRAMEDIR}/mf || error "'${FILE}' failed"
fi
Many thanks for your awesome and very professional support!