필터 지우기
필터 지우기

How can I avoid artifacts when I use im2frame to convert black-and-white images to frames for a video?

조회 수: 5 (최근 30일)
My function creates a series of 2D black-and-white uint8 images. These display perfectly as individual images, but when I try to make a video with them using im2frame, the lines in the frames are enclosed in salt-and-pepper squares that I assume are some king of artifiact:

채택된 답변

Stuart Smith
Stuart Smith 2022년 2월 4일
I was able to get clean black-and-white line images with this code:
function y = linedrwg( inpict )
img = rgb2gray( inpict ) ;
binimg = not( imbinarize( edgemap( img ) ) ) ;
binimg = bwmorph( binimg , 'clean' ) ;
[ r , c ] = size( binimg ) ;
y = zeros( r , c , 3 ) ;
y( : , : , 1 : 3 ) = binimg ;
end

추가 답변 (1개)

Benjamin Thompson
Benjamin Thompson 2022년 2월 1일
If you are using VideoWriter to write out the video file with frames you get from im2frame, use an uncompressed or lossless compression profile. The default 'Motion JPEG AVI' profile and any MPEG-4 profile will have a quality parameter that typically allows for improved compression at the expense of artifacts or blurring of edges.
'Archival'
Motion JPEG 2000 file with lossless compression
'Motion JPEG AVI'
AVI file using Motion JPEG encoding
'Motion JPEG 2000'
Motion JPEG 2000 file
'MPEG-4'
MPEG-4 file with H.264 encoding (systems with Windows 7 or later, or macOS 10.7 and later)
'Uncompressed AVI'
Uncompressed AVI file with RGB24 video
'Indexed AVI'
Uncompressed AVI file with indexed video
'Grayscale AVI'
Uncompressed AVI file with grayscale video
  댓글 수: 1
Stuart Smith
Stuart Smith 2022년 2월 2일
I tried all of the profiles listed above. 'Archival' and 'Motion JPEG 2000' produce the error 'unsupported data type double for the chosen file type.' The other profiles produce video with the same artifiacts as in my original post.
Should the images I'm using to make frames be indexed or truecolor, or doesn't it matter?
Thanks for your help.

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by