9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] shrinking an Image?
@ 2006-08-26 21:13 Axel Belinfante
  2006-08-26 21:21 ` andrey mirtchovski
  2006-08-26 21:22 ` Federico Benavento
  0 siblings, 2 replies; 14+ messages in thread
From: Axel Belinfante @ 2006-08-26 21:13 UTC (permalink / raw)
  To: 9fans

Is there a good/easy/general way to shrink an Image?
(read 'arbitrary' image, shrink it, then use shrunken Image)
in this particular case: to a quarter of its size (48x48 -> 24x24),
where the Image is read from a face file
(I guess it amounts to computing a single pixel
  for every four of the original, but how?)

Axel. - trying to improve a bitsy sized rushhour, looks like
touch screens are easier for small children than mice


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-26 21:13 [9fans] shrinking an Image? Axel Belinfante
@ 2006-08-26 21:21 ` andrey mirtchovski
  2006-08-27  7:51   ` lucio
  2006-08-27 17:20   ` Axel Belinfante
  2006-08-26 21:22 ` Federico Benavento
  1 sibling, 2 replies; 14+ messages in thread
From: andrey mirtchovski @ 2006-08-26 21:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 8/26/06, Axel Belinfante <Axel.Belinfante@cs.utwente.nl> wrote:
> Is there a good/easy/general way to shrink an Image?

would resample(1) do?

http://swtch.com/plan9port/man/man1/resample.html


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-26 21:13 [9fans] shrinking an Image? Axel Belinfante
  2006-08-26 21:21 ` andrey mirtchovski
@ 2006-08-26 21:22 ` Federico Benavento
  1 sibling, 0 replies; 14+ messages in thread
From: Federico Benavento @ 2006-08-26 21:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

resample(1)

On 8/26/06, Axel Belinfante <Axel.Belinfante@cs.utwente.nl> wrote:
> Is there a good/easy/general way to shrink an Image?
> (read 'arbitrary' image, shrink it, then use shrunken Image)
> in this particular case: to a quarter of its size (48x48 -> 24x24),
> where the Image is read from a face file
> (I guess it amounts to computing a single pixel
>   for every four of the original, but how?)
>
> Axel. - trying to improve a bitsy sized rushhour, looks like
> touch screens are easier for small children than mice
>


-- 
Federico G. Benavento


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-26 21:21 ` andrey mirtchovski
@ 2006-08-27  7:51   ` lucio
  2006-08-27 14:37     ` Russ Cox
                       ` (2 more replies)
  2006-08-27 17:20   ` Axel Belinfante
  1 sibling, 3 replies; 14+ messages in thread
From: lucio @ 2006-08-27  7:51 UTC (permalink / raw)
  To: 9fans

> would resample(1) do?

I find that resample(1) is not visually as faithful as (even?)
page(1)'s built-in resizer.  I have not explored the possible causes,
however.  For JPEG and 2, 4, 8 times resizing (shrinking) I find the
cjpeg | djpeg combination to be preferable.

++L



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27  7:51   ` lucio
@ 2006-08-27 14:37     ` Russ Cox
  2006-08-27 16:45       ` lucio
  2006-08-27 15:09     ` erik quanstrom
  2006-08-28 22:17     ` Steve Simon
  2 siblings, 1 reply; 14+ messages in thread
From: Russ Cox @ 2006-08-27 14:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I find that resample(1) is not visually as faithful as (even?)
> page(1)'s built-in resizer.  I have not explored the possible causes,
> however.

They should behave identically.
Page's zoom function uses a copy of the resample code.

Russ


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27  7:51   ` lucio
  2006-08-27 14:37     ` Russ Cox
@ 2006-08-27 15:09     ` erik quanstrom
  2006-08-27 16:46       ` lucio
  2006-08-27 17:34       ` Axel Belinfante
  2006-08-28 22:17     ` Steve Simon
  2 siblings, 2 replies; 14+ messages in thread
From: erik quanstrom @ 2006-08-27 15:09 UTC (permalink / raw)
  To: 9fans

in light of russ' comment, could it be that you are not using the -t
option for jpg?  the default for jpg/png/etc is to downsample to 8 bits.
page actually uses "-t9" as it's options.  i've been burned by this 
many times.  perhaps jpg should default to depth 24 when being
used as a filter.

- erik

On Sun Aug 27 02:55:23 CDT 2006, lucio@proxima.alt.za wrote:
> > would resample(1) do?
> 
> I find that resample(1) is not visually as faithful as (even?)
> page(1)'s built-in resizer.  I have not explored the possible causes,
> however.  For JPEG and 2, 4, 8 times resizing (shrinking) I find the
> cjpeg | djpeg combination to be preferable.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27 14:37     ` Russ Cox
@ 2006-08-27 16:45       ` lucio
  0 siblings, 0 replies; 14+ messages in thread
From: lucio @ 2006-08-27 16:45 UTC (permalink / raw)
  To: 9fans

> They should behave identically.
> Page's zoom function uses a copy of the resample code.

It was a long time ago (maybe a couple of years) that I last used
resample(1) and the results were disappointing.  I have not checked
whether it has been revamped recently.  And perhaps I was using it
sub-optimally, as I was almost certainly applying it to GIFs or JPEGs.

I do recall noting that page(1) did a more faithful job.  If memory
serves, I may be able to try it again on the same image, but I make no
promises.

++L



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27 15:09     ` erik quanstrom
@ 2006-08-27 16:46       ` lucio
  2006-08-27 17:34       ` Axel Belinfante
  1 sibling, 0 replies; 14+ messages in thread
From: lucio @ 2006-08-27 16:46 UTC (permalink / raw)
  To: 9fans

> in light of russ' comment, could it be that you are not using the -t
> option for jpg?  the default for jpg/png/etc is to downsample to 8 bits.
> page actually uses "-t9" as it's options.  i've been burned by this 
> many times.  perhaps jpg should default to depth 24 when being
> used as a filter.

Could be, I did not spend much time on it.

++L



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-26 21:21 ` andrey mirtchovski
  2006-08-27  7:51   ` lucio
@ 2006-08-27 17:20   ` Axel Belinfante
  1 sibling, 0 replies; 14+ messages in thread
From: Axel Belinfante @ 2006-08-27 17:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> > Is there a good/easy/general way to shrink an Image?
> 
> would resample(1) do?

thanks, I succeeded to overlook it.

resample(1) contains a reference to crop(1);
it might be nice to add a reverse ref in crop(1)


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27 15:09     ` erik quanstrom
  2006-08-27 16:46       ` lucio
@ 2006-08-27 17:34       ` Axel Belinfante
  2006-08-27 17:46         ` andrey mirtchovski
  2006-08-27 18:22         ` erik quanstrom
  1 sibling, 2 replies; 14+ messages in thread
From: Axel Belinfante @ 2006-08-27 17:34 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Now that you mention this, for one plan 9 image that I converted
using togif and tojpg I had better results after first converting
it using 'iconv -c m8'.
Was I 'unlucky' in needing this additional step, or is that
the usual procedure?

Axel.

> in light of russ' comment, could it be that you are not using the -t
> option for jpg?  the default for jpg/png/etc is to downsample to 8 bits.
> page actually uses "-t9" as it's options.  i've been burned by this 
> many times.  perhaps jpg should default to depth 24 when being
> used as a filter.
> 
> - erik
> 
> On Sun Aug 27 02:55:23 CDT 2006, lucio@proxima.alt.za wrote:
> > > would resample(1) do?
> > 
> > I find that resample(1) is not visually as faithful as (even?)
> > page(1)'s built-in resizer.  I have not explored the possible causes,
> > however.  For JPEG and 2, 4, 8 times resizing (shrinking) I find the
> > cjpeg | djpeg combination to be preferable.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: [9fans] shrinking an Image?
  2006-08-27 17:34       ` Axel Belinfante
@ 2006-08-27 17:46         ` andrey mirtchovski
  2006-08-27 18:22         ` erik quanstrom
  1 sibling, 0 replies; 14+ messages in thread
From: andrey mirtchovski @ 2006-08-27 17:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

i seem to remember tojpg and friends doing a floyd-steinberg error
diffusion to downsample to 8bpp by default.

see the difference in these two (rather old) screenshots, the first
taken with topng, the second most likely from a running drawterm:

http://pages.cpsc.ucalgary.ca/~mirtchov/screenshots/scr-plan9.png

http://pages.cpsc.ucalgary.ca/~mirtchov/screenshots/scr-1.png

the acme titles experience the most obvious deviation.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27 17:34       ` Axel Belinfante
  2006-08-27 17:46         ` andrey mirtchovski
@ 2006-08-27 18:22         ` erik quanstrom
  1 sibling, 0 replies; 14+ messages in thread
From: erik quanstrom @ 2006-08-27 18:22 UTC (permalink / raw)
  To: 9fans

you could have skipped this step by disabling error diffusion.
the bugs section of iconv(1) mentions this.

i think the main problem with the current error diffusion is that
the scan always goes from left to right.  a simple fix might be to
alternate the scan from left-to-right then right-to-left.  also, the
error diffusion needs to be extended beyond 3 color channels
(for example, to b&w).

perhaps i don't understand the problem properly, but i think it
might make sense to remove the error diffusion from jpg and friends
and add it to iconv.

- erik


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-27  7:51   ` lucio
  2006-08-27 14:37     ` Russ Cox
  2006-08-27 15:09     ` erik quanstrom
@ 2006-08-28 22:17     ` Steve Simon
  2006-08-28 23:07       ` erik quanstrom
  2 siblings, 1 reply; 14+ messages in thread
From: Steve Simon @ 2006-08-28 22:17 UTC (permalink / raw)
  To: 9fans

> I find that resample(1) is not visually as faithful as (even?)
> page(1)'s built-in resizer.  I have not explored the possible causes,
> however.  For JPEG and 2, 4, 8 times resizing (shrinking) I find the
> cjpeg | djpeg combination to be preferable.

Just a guess, but prehaps page does resample in screen space 
(e.g. 16bpp) whereas resample(1) probably runs faithfully in YUV
(well, more likely RGB) space. This could easily have the effect of
amplifying the JPEG compression artiacts. Resampling in the incorrect
gamma land can also have strange effects like this.

-Steve


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [9fans] shrinking an Image?
  2006-08-28 22:17     ` Steve Simon
@ 2006-08-28 23:07       ` erik quanstrom
  0 siblings, 0 replies; 14+ messages in thread
From: erik quanstrom @ 2006-08-28 23:07 UTC (permalink / raw)
  To: 9fans

the algorithm is exactly the same.  both convert the image to 8 bits-per-channel then resample
using a kaiser window.  no 16 bit channel or alternate colorspaces anywhere.

- erik



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2006-08-28 23:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 21:13 [9fans] shrinking an Image? Axel Belinfante
2006-08-26 21:21 ` andrey mirtchovski
2006-08-27  7:51   ` lucio
2006-08-27 14:37     ` Russ Cox
2006-08-27 16:45       ` lucio
2006-08-27 15:09     ` erik quanstrom
2006-08-27 16:46       ` lucio
2006-08-27 17:34       ` Axel Belinfante
2006-08-27 17:46         ` andrey mirtchovski
2006-08-27 18:22         ` erik quanstrom
2006-08-28 22:17     ` Steve Simon
2006-08-28 23:07       ` erik quanstrom
2006-08-27 17:20   ` Axel Belinfante
2006-08-26 21:22 ` Federico Benavento

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).