Lossless compression in Motion JPEG 2000 (.mj2) file. How do I tell?

조회 수: 13 (최근 30일)
Spencer Chen
Spencer Chen 2016년 8월 9일
답변: Janosch Kunczik 2017년 6월 13일
I found that Matlab's VideoWriter has the capability to write a Motion JPEG 2000 file with the LosslessCompression flag. Is there a way to find out whether images in a Motion JPEG 2000 file has been compressed losslessly?

답변 (1개)

Janosch Kunczik
Janosch Kunczik 2017년 6월 13일
Hello Spencer,
Yes there is a way:
  1. Take an (raw) image sequence or video file and use the VideoWriter to create a .mj2 video.
  2. Use the VideoReader to read the video frame by frame
  3. Compare both
%%Write the video
writer = VideoWriter('test.mj2','Motion JPEG 2000');
writer.LosslessCompression = true;
for i=1:length(testData)
writeVideo(writer,testData(:,:,:,i));
end
close(writer);
vidObj = VideoReader('test.mj2');
for i=1:length(testData)
frame = readFrame(vidObj);
orig_frame = rawObj.Data(i).frame;
error = frame - orig_frame;
disp(max(max(abs(error)));
end
This little snippet will let you prove that the result isn't lossless, although the LosslessCompression flag has been set.
I you want to have a lossless Motion JPEG 200 video, you will have to use the 'Archival' profile.
writer = VideoWriter('test.mj2','Archival');
Kind regards,
Josh

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by