----------------------------------------------------------------------------- BLOCK IMAGE QUANTIZER V1 - (C) 1999 NAVEED KHUGIANI / ALGOTECH SOFTWARE ----------------------------------------------------------------------------- DISCLAIMER ---------- This program does not include any warranty of any kind. No responsibility will be taken for anything that may happen by the use of this program. Use at your own risk. INTRODUCTION ------------ There are various methods of compressing image data, the most popular method hovewer is 'lossy' compression. Images can take up a lot of disk space and the compressibility of these images (especially digitized images) is not too good. 'lossy' compression reduces or transforms the data before main compression making it very easy to give a better compression ratio. What is important hovewer is to reduce the data in the image without degrading the quality of the image too much and to make the compression / decompression routine run very fast even on a 68000 7mhz processor. This is the purpose of the 'BlockImageQuantizer' image compressor. WHAT EXACTLY DOES IT DO ----------------------- This small utility compresses greyscale image data by analysing small blocks in the image and deciding whether to quantize the block or to leave it alone. This is determined by the quantization parameter allowing the user to select the quantization level. Finally the quantized and non quantized data are joined together. This is only a semi compressor. The data can even be compressed further by about 30% when using LZ based compression. Compressed images can be viewed or saved in one of 3 file formats with preimage smoothing to reduce the 'blockiness' of images with high quantization levels. SYSTEM REQUIREMENTS ------------------- It should work on any Amiga system with any kickstart version and processor. It requires approximately 256k of ram while compressing/viewing or decompressing a file. It has only been tested on a 2 meg chip A500+. If there are any problems, dont hesitate to contact me with a description of the bug(s)?? PROGRAM SYNTAX -------------- COMPRESSING AN IMAGE BImageQuantizer -c [destfile] [-l#] -q# is the name of the image data to compress. Currently it can only be a uncompressed ILBM file (320x256 16 level linear greyscale) If the'-l#' parameter is used, Raw Planar or Chunky images can be processed by the program. [destfile] is optional and is the name of the compressed file to create. If this is not included. The compressed data will have the same filename as the sourcefile with the added extension .BIQ -l# is the load format parameter and is followed by a number... -l1 : Load Raw Planar Image (40960 bytes) -l2 : Load Chunky image (81920 bytes) This parameter must be used if the data is a RAW file. -q# is the quantization parameter. The quantization number can be anything from 1 to 99. (eg. -q18) DECOMPRESSING AN IMAGE BImageQuantizer -d -s# -h is the name of the compressed image. It must be a valid BIQ compressed file. is the name of the decompressed image file to create. -s# is the save format. -s1 : Save as IFF ILBM (Uncompressed) -s2 : Save as Raw Planar (40960 bytes) -s3 : Save as Chunky (81920 bytes) -h This parameter is optional, but interpolates the image before saving it. It should only be used if the compressed image was quantized very heavily FOR VIEWING BImageQuantizer -v -h is the name of the compressed BIQ file. -h is optional, but interpolates the image before displaying it. Yet again, it should only be used if the compressed image was quantized heavily. IMPORTANT NOTE : It seems that this program can only accept a very limited range of IFF ILBM files. I have no documentation on the IFF ILBM format and I did not want this program to rely on any other External libraries for its function. for this reason, this program can only accept IFF ILBM files saved by the 'VidiGrab' FrameGrabber software (Supplied with the VidiAmiga digitizer.) IFF Files should be converted to Either RAW Planar or RAW Chunky using other utilities such as PicCon or GFXMaster. These files can then be used by this compressor along with the load parameter. LIMITATIONS ----------- This compressor can ONLY work on greyscale images in 16 shades with a linear palette (Colour 0 must start from black and gradually increase to white) The size of the image must also be 320x256 These Limitations can easily be overcome, But I want to see the response from this program before I decide to create another version. HINTS AND TIPS -------------- CONVERTING AN IMAGE FOR THE BIMAGEQUANTIZER As stated before. There are a lot of restrictions on the IFF ILBM load format used by this program. It is advisable to convert the image to either raw planar or raw chunky for use with this program If the image is using different colours and/or a different size... A: Convert the image to 16 shade greyscale using a suitable art package/image processor B: Remap the colours to a linear greyscale palette starting from black and gradually increasing to white if it is not already done. C: Crop or scale the size to 320x256 and save the image D: Use a Raw image converter (Such as GFXMaster) to convert the image to either Planar or Chunky (The palette is not important anymore) The converted Planar filesize has to be exactly 40960 bytes and the converted Chunky filesize has to be exactly 81920 bytes. E: This file can now be used with this compressor by using the '-l' parameter followed by a number * Smoothing an image before compression can increase the compression ratio of a compressed file at the expense of some blurring. * Images with large single colour area's or smooth intensity changes spread over large sections of the image can increase the compression ratio dramatically * The Amount of data quantized depends on the nature of the Image. Some images give little degradation in quality even when using high quantize values while others can give very large degradation even when using low quantization values. Experimentation is required with the quantization values. * This compressor should ONLY be used on complex digitized images. (It was originally intended to be used in conjuction with the VidiAmiga digitizer) * Avoid compressing images which feature text. This compressor will in most cases avoid quantizing anything with high intensity changes (eg: bright text on average/dark digitized background) reducing the compression ratio dramatically. * The Image should have good dynamic range. Attempting to compress Dull images or images with too much contrast can reduce compression ratio or increase quantization levels. EXAMPLES -------- Compressing A Raw Planar file called 'testpic.raw' to comppic.biq with a quantization value of 20 BImageQuantizer -c testpic.raw comppic.biq -l1 -q20 Decompressing a BIQ File called comppic.biq to an IFF ILBM file called 'test.iff' with interpolation BImageQuantizer -d comppic.biq test.iff -s1 -h Viewing a BIQ File called comppic.biq with no interpolation BImageQuantizer -v comppic.biq This archive contains 3 image files. TestImage.iff : This is the original IFF image with no degradation TestImage.raw : Same as Above, but in RAW Planar format. Use this for experimenting. TestImage.biq : A compressed BIQ file of the above image with a quantisation level of 16. FILE SIZES ---------- Some examples on the compressed file sizes achieved with this program. FILENAME COMPRESSED SIZE ADDITIONAL COMPRESSION QUANTIZATION WomanFaceAdvert 8436 6894 16 LiveSatWomanPic 9262 7344 20 All Files would have normally took up 40k as an IFF ILBM file and even with compression it would probably be in the region of 27k-28k Furthermore when using decent quantization values, Only the less important image sections get quantized leaving the important sections alone. TECHNICAL --------- This program performs quantization according to the contents of the current block it is analysing. The analyser 'looks' at the complexity of this block and decides whether to quantize it to 1 colour value or to leave it alone. This is determined by the quantization value given in the program parameter. Normally once an image has been quantized and compressed, Most image sections with less complex data or smooth intensity changes will be quantized to 1 block value. The compression is very basic. While the data is being analysed and quantized, the Non quantized and quantized data are nybble merged and transferred to a buffer with a seperate flagbuffer being created for the decompressor. The great advantage in this is that the data can be compressed even further. (eg: a 10k compressed file can be compressed to around 7k) This program has been specifically developed to run on a 68000 processor. It is written in 100 percent assembly, less than 10k in size + compresses and decompresses an image in seconds on a 68000 7Mhz processor. The compression and decompression speeds can be improved dramatically by using a different method of writing and reading compressed data. Currently it compresses data 1 bit at a time... THIS PROGRAM IS FREEWARE ------------------------ This program is entirely freeware, Enjoy using the program and feel free to send me some comments. I can be contacted at: EMAIL naveedkhugiani@students.elatt.org.uk (Note: Only until 24th july 1999) SNAILMAIL Naveed Khugiani, 12 Huntshaw House, Devons road, Bow, London, E3, 3NR OTHER RELEASED PROGRAMS ----------------------- All the below programs are available from the Amiga Internet archive 'AMINET' BWToGrey : This small utility will convert a black and white image to full greyscale in seconds with additional preview and various save formats. BRLECompressor : Another Image compressor which compresses greyscale image data in seconds with no loss in quality and a better compression ratio than most compressors. Can be used as a slideshow viewer enabling the user to fit dozens of greyscale images on 1 disk.