Java Compressing an Image using Arrays 2D to 1D? -


i having trouble assignment of mine. have class reads in pgm image files. need create few classes, main 1 being compression class. need compress pgm (represented 2d arrays) 1d array.

here instructions:

public static short[] compress(short[][])  
  • is passed 2d array of shorts represents image.
  • returns compressed image 1d array of shorts.
  • that method main concern.

compression idea:

  • look horizontal or vertical runs of pixel values , record number of times pixel value repeated itself.
  • note spektre: called rle run length encoding used pcx example

algorithm:

1.compute compressed image array using horizontal runs

2.compute compressed image array using vertical runs

3.choose compress image uses best technique particular image.

4.set header of image

  • set first , second values of short [ ] result array width , height values.
  • set third value in short[ ] result array 1 horizontal or 2 vertical compression.

5.set image body

  • the rest of short [ ] result array filled rle quantity , value

there few other methods

  • if wants them:

    public static void write(short[], string)  
  • is passed 1d array of shorts represents compressed image , desired filename.

  • simply write values text file .compressed extension added filename.

    public static short[] read(string)  
  • is passed compressed image filename.

  • simply reads values , returns them in 1d array of shorts.

    public static short[][] decompress(short[])  
  • is passed 1d array of shorts represents compressed image.

  • simply decompress file can display on screen
  • using our showgrayimage( ) code have.

thanks in advance!


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -