From: Walter Roberson on
Duane Hanselman wrote:
>
>> You could take the average of the three channels, then threshold the
>> mean to get a black-white representation.
>>
>> >> a=rand(10,8,3);
>> >> a=mean(a,3)>.5;
>> >> imwrite(a,'binary.tif');
>> >> info = imfinfo('binary.tif');
>> >> info.BitsPerSample
>
>
> That almost works. The figure is 1 bit, but it now has a bunch of
> unwanted random one pixel wide horizontal lines in it.
>
> I changed the threshold value to >0 and >0.99 but the spurious lines
> remain in the same place.

I would _try_ using 'Compression', 'none' in the imwrite() call.
According to the documentation it should already be lossless, but it
doesn't hurt to be sure.
From: Ashish Uthama on
On Mon, 24 May 2010 18:14:17 -0400, Walter Roberson
<roberson(a)hushmail.com> wrote:

> Ashish Uthama wrote:
>> On Mon, 24 May 2010 15:20:05 -0400, Duane Hanselman
>> <masteringmatlab(a)yahoo.spam.com> wrote:
>
>> You could take the average of the three channels, then threshold the
>> mean to get a black-white representation.
>
> However, that would be relatively unusual. You would normally use a
> weighted average rather than an equal average. The appropriate weights
> are known to rgb2gray() and you could then im2bw() the result. You may
> also wish to use graythresh() to compute the appropriate threshold.

OP:
"I do not have the image processing toolbox, so I need something I can
implement without it. The original image is bw so, 1 bit should be fine."

I should have been more clear that this is a 'workaround'. I also just
realized the 'bw' part. You could as well just use one of the channels
from the RGB image: (A grayscale/BW image represented in RGB terms implies
that all three components have the same value).

a=rand(10,8,3);
a=mean(a(:,:,1),3)>.5;