From: Duane Hanselman on 24 May 2010 15:20 I would like to save a figure window as a one bit tif file. print -dtiff saves a 24 bit tiff. I can read the tiff back into MATLAB easy enough. How do I convert it to 1 bit tiff and resave it? I have been around MATLAB for almost 30 years, but I am not a image processing person. 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. Duane
From: Ashish Uthama on 24 May 2010 15:52 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. >> a=rand(10,8,3); >> a=mean(a,3)>.5; >> class(a) ans = logical >> imwrite(a,'binary.tif'); >> info = imfinfo('binary.tif'); >> info.BitsPerSample ans = 1
From: Duane Hanselman on 24 May 2010 16:31 > 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. Now what? Thanks. Duane
From: Ashish Uthama on 24 May 2010 17:19 On Mon, 24 May 2010 16:31:21 -0400, Duane Hanselman <masteringmatlab(a)yahoo.spam.com> wrote: Cant say more without looking at the image / repro steps.
From: Walter Roberson on 24 May 2010 18:14 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.
|
Next
|
Last
Pages: 1 2 Prev: Non-Linear Frequency Response Next: Using ginput or related fuction to "connect the dots" |