permaculture playing cards*
The moose likes Java in General and the fly likes little help with assignment - java program that reads/writes image/pixel data raw.:-( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "little help with assignment - java program that reads/writes image/pixel data raw.:-(" Watch "little help with assignment - java program that reads/writes image/pixel data raw.:-(" New topic
Author

little help with assignment - java program that reads/writes image/pixel data raw.:-(

java nubee
Greenhorn

Joined: Mar 09, 2006
Posts: 4
Hi There
I am looking for a push in right direction in relation to an assignment (ref below). I've got the read bit ok (i.e image into an array that is RGB no-alpha), but just a little unsure about what is next.

Please help :-)

==================================================================

Write a Java program which reads an image in a popular format and saves the pixel data in a raw format. The program must be command line based with two arguments: the first argument is the image file in a popular format and the second argument specifies the file you save your raw image data with extension raw. The first line of the raw format file must be "grey image" if the image is grey or "colour image" if the image is colour. The second line must specify the dimension in two fields: the first field represents the width and the second field represents the height. An example metadata of the raw format is as follows:

colour image
256 256

The second part of the assignment requires you to develop your own Java image codec which can compress the raw format images of part A (above). The encoder can be very simple one however it must contain at least the following:

a) Transform coding stage
b) Quantization stage
c) Entropy coding stage

The compressed image must be saved to a file with extension jif. Any parameters you used for the compression must be saved except those parameters which don?t depend on a particular image. A corresponding decoder program must also be produced.
===================
-Cheers
Craig :-)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, in the second half of part "A", you'd open a file and write out the data. It sounds like they want a text format, based on the wording. So you could use a PrintWriter wrapping a FileWriter, write the two header lines, and then just write the pixel values for each row on successive lines.


[Jess in Action][AskingGoodQuestions]
java nubee
Greenhorn

Joined: Mar 09, 2006
Posts: 4
Yer
Wasn't sure to use ImageIO.write class or a binary IO.

Hmmmm....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: little help with assignment - java program that reads/writes image/pixel data raw.:-(