필터 지우기
필터 지우기

Saving a Bilevel - or Binary Image

조회 수: 2 (최근 30일)
Matthew Moynihan
Matthew Moynihan 2011년 1월 26일
Hello,
I am creating a black and white movie in my code. I create a 4 dimensional matrix of zeros. Each number in the matrix is a uint8. This is the problem.
B = zeros(X, Y, 1, NumberOfFrames);
B = uint8(B);
All I want to save is a 1 and a 0. By doing a unit8 I add 7 extra bits to each pixel. This is over a 25 minute mov file!! How can I save the information using less memory? Is there for example an:
B = binary(B);
Command?
Thanks!

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 1월 26일
B = false(X, Y, 1, NumberOfFrames); %casts as logical (1bit)
or
B = logical(B); %for something already in black and white but not 1bit

Siddharth Shankar
Siddharth Shankar 2011년 1월 26일
B = zeros(X, Y, 1, NumberOfFrames);
B = logical(B);
is what you are looking for. More info here: Logical Types
  댓글 수: 3
Matthew Moynihan
Matthew Moynihan 2011년 1월 27일
Yes, I know, I used the Repmat function to duplicate the logical value.
Siddharth Shankar
Siddharth Shankar 2011년 1월 27일
Sean, the code provided above is by no means meant to be "best practice" or the "best way" to do something. I was simply working off the code that "justthebasics" provided. The key was to make him aware of the LOGICAL function.

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by