Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!d45g2000hsc.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: reduce size of high-quality image
Date: Sun, 20 Apr 2008 12:57:21 -0700 (PDT)
Organization: http://groups.google.com
Lines: 65
Message-ID: <abbe2799-9dfe-4eaa-b37e-89b02436e73f@d45g2000hsc.googlegroups.com>
References: <fufvs2$m68$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1208721442 29015 127.0.0.1 (20 Apr 2008 19:57:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 20 Apr 2008 19:57:22 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: d45g2000hsc.googlegroups.com; posting-host=75.186.67.199; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
Xref: news.mathworks.com comp.soft-sys.matlab:464177


On Apr 20, 1:52=A0pm, "dormant " <rod.stew...@uwiseismic.com> wrote:
> I need to reduce the size of a high quality image, read from
> a TIFF file.
>
> Say I want to reduce the image size by a factor of N
> (normally 4). I would average the image using NxN blocks,
> then decimate by N and use the output to create a new image.
>
> But that would lose the increase in dynamic range that comes
> from the averaging process. I want to retain that dynamic
> range somehow, which means I have to change variable type
> and then somehow create an image file that uses uint16 or
> floating point values.
>
> I've had a stab at this, but can't get anywhere. I can't
> even get blkproc to work as follows:
>
> >> fun =3D @mean2;
> >> IM2 =3D blkproc( IM1, [4 4], fun);
>
> ??? Subscripted assignment dimension mismatch.
>
> Error in =3D=3D> blkproc at 89
> aa(border(1)+(1:ma),border(2)+(1:na)) =3D a;
>
> Any suggestions for:
>
> 1) How to get over the blkproc problem.
>
> 2) How to add the precision change.

dormant:
You probably realize by now that you misspoke when you said that the
averaging process causes an increase in dynamic range, and you want to
keep this increase.  In fact, averaging (blurring) DEcreases dynamic
range, as a window containing a pixel with the peak brightness will be
brought down to a lesser average value and a window containing a pixel
with the minimum brightness will be brought up to a higher average
value, unless of course the entire window contained nothing but the
peak or darkest value.

What do you mean when you say "dynamic range"?  If all you wanted to
do was to make sure that pixels with the greatest and least value were
retained and not replaced by the average within the window, you could
do that with some special custom written locally adaptive window
processing code.  For example, take the morphological gray scale
dilation of the image (to get the max values in the window), then the
erosion (to get the mins), then the median or average (to get a mid-
level value).  Then you could say something like if the window
contains the max, or the average is in the upper third of the dynamic
range, then take the value  from the dilation.  If the mean is in the
middle third of values, then take the mean or median.  If the mean is
in the darkest third of values, take the erosion value.  There are
lots of schemes you could think up, so there is no one right answer.
(I'm assuming you have the image processing toolkit.)

Why is keeping the dynamic range so important?  What if the entire
image lay between 100 and 150 gray levels and you had one sole pixel
at 230 and one sole pixel at 20.  Would you want your subsampled image
to go between 100 and 150 (I would) or would you (for some, as of yet
unstated, reason) want it to go between 20 and 230 even though it was
just due to two spurious (probably noise) pixels that gave you the
wider dynamic range?
Regards,
ImageAnalyst