Fastest way to 'rescale' a b&w image?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pitosalas

Fastest way to 'rescale' a b&w image?

Post by pitosalas »

I have a 200x200 black and white image - see end for the identify output for it.

I would like to change it into a 100x100 black and white image. Right now I am using the API, doing the equivalent of a -rescale (which seemed to change it to greyscale) and then a bilevel-chanel to make it true ones and zeros again (well, 65,535 and 0). My image analysis is simple enough that b&w seems to be good enough.

What is the very fastest way to do it?

Thanks!

Pito

p.s. Here is the 'identify' output for the source.


Identify -verbose /Volumes/ExternalHD2/Ballots/Leon/EV976-29/work/2819-1.TIF
Image: /Volumes/ExternalHD2/Ballots/Leon/EV976-29/work/2819-1.TIF
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 2563x4260+0+0
Resolution: 300x300
Print size: 8.54333x14.2
Units: PixelsPerInch
Type: Bilevel
Base type: Bilevel
Endianess: MSB
Colorspace: RGB
Depth: 1-bit
Channel depth:
gray: 1-bit
Channel statistics:
gray:
min: 0 (0)
max: 1 (1)
mean: 0.891633 (0.891633)
standard deviation: 0.310844 (0.310844)
kurtosis: 4.3494
skewness: -2.5198
Histogram:
9735183: (255,255,255) #FFFFFF white
1183197: ( 0, 0, 0) #000000 black
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Page geometry: 2563x4260+0+0
Dispose: Undefined
Iterations: 0
Compression: Group4
Orientation: TopLeft
Properties:
create-date: 2009-07-01T21:26:10-04:00
modify-date: 2009-06-04T00:10:09-04:00
signature: 3b6de946897afa4dd571f8e37f224c852ef3d0b5a5325fb4f4d83cf83c39fe0b
tiff:rows-per-strip: 4260
tiff:software: Pixel Translations Inc., PIXTIFF Version 56.0.218.1093
Artifacts:
verbose: true
Tainted: False
Filesize: 217kb
Number pixels: 10.41mb
Version: ImageMagick 6.5.1-0 2009-04-24 Q16 http://www.imagemagick.org
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Fastest way to 'rescale' a b&w image?

Post by anthony »

The best way depends on the image,

It is a black and which shape, or does it contain thin lines that need to be preserved?

The former can be just use -sample, (see http://www.imagemagick.org/Usage/resize/#sample as to why this has problems for thin lines.

The later needs either to be resized and thresholded (for small size changes) or some morphology operators applied to thicken the lines first (for larger size changes).

If enlarging their are other techniques. some of which has not been implemented in IM, to make the bitmap image look better at the larger scales, while allowing it to remain a bitmap.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply