HW1 , computer problem.
EECS 203A
UCI Fall 2004
by Nasser Abbasi
Oct 4, 2004
Solution to the computer problem
part of the HW
Steps to run the matlab function
See instructor hand out here
I have written a matlab function to implement the subsampling (shrink) and then to oversample these shrunk images back to the original 480 by 640 raw images.
Here are misc. notes I’ve written while working on this problem but not necessary to hand out.
Below I show the output of the matlab function, which is a total of 8 image files.
Then I show the matlab function to implement this. The matlab function generates raw image files, and then the program rawtoras (on Sun machine) is used to convert these raw images to raster format.
For shrinkage (undersample), this is the easy part. Using the shrinkage factor, determine number of rows and columns to remove from the original image.
For zooming (oversample), There are 2 algorithms to use. The nearest neighbor method where the value of each new pixel added to the new image is obtained from the value of the pixel in the original image by finding the closest pixel in the original image to the new pixel in the new image. The other algorithm is the bilinear mapping algorithm. We are asked to use the nearest neighbor algorithm for zooming and this is what I implemented.
All the 16 output files (in raw and raster format) are contained inside this one tar file hw1.tar
$ tar tf hw1.tar
cat.raw
cati16.raw
cati4.raw
cats16.raw
cats4.raw
triangle.raw
trianglei16.raw
trianglei4.raw
triangles16.raw
triangles4.raw
cat.ras
cati16.ras
cati4.ras
cats16.ras
cats4.ras
triangle.ras
trianglei16.ras
trianglei4.ras
triangles16.ras
triangles4.ras
Below is each image listed, for each image a raw and raster file format is shown
Cat.raw This is the original cat raw image file given to use by the instructor
Cats4.raw cats4.ras This is the shrunk (subsample) image by factor of 4, in raw and raster formats
Cats16.raw cats16.ras ras This is the shrunk (subsample) image by factor of 16 in raw and raster formats
Cati4.raw cati4.ras This is the zoomed (oversample) image by factor of 4 generated from cats4.raw, in raw and raster formats
Cati16.raw cati16.ras ras This is the zoomed (oversampled) image by factor of 16 generated from cats16.raw, in raw and raster formats
triangle.raw This is the original triangle raw image file given to use by the instructor
triangles4.raw triangles4.ras This is the shrunk (subsample) image by factor of 4 , in raw and raster formats
triangles16.raw triangles16.ras ras This is the shrunk (subsample) image by factor of 16, in raw and raster formats
trianglei4.raw trianglei4.ras This is the zoomed (oversample) image by factor of 4 generated from triangles4.raw, in raw and raster formats
trianglei16.raw trianglei16.ras This is the zoomed (oversampled) image by factor of 16 generated from triangles16.raw, in raw and raster formats
2 matlab functions are written, one to implement the subsampling and oversampling, and another matlab support function written to test the output.
nma_HW1_ece203A_UCI.m This is the matlab function to implement the problem.
nma_test_HW1_EECS_203A.m This matlab function for testing the output of the above function.
This program rawtoras only runs on sun. I was not able to find the source code for this file or a port to Linux, so I needed to login to Sun machine each time to use this. Any one knows how to find the source code for this program?
The C program rw.c provided to us by the instructor to show how to read and write 8 bits per pixle raw image. I did not use this since I used matlab, but this can be usefull to have.
This matlab function readras.m readras.m written by Peter J. Acklam, and and I found doing google while working on this problem. I did not use this file but it can be usefull as reference if needed.
While searching for source code for rawtoras, I found source to do this written by Richard Alan Peters II, Assistant Professor of Electrical Engineering in 1994. This package contains many tools and one of the tools is a program called raw2ras. This is part of a package called morph, which is still available on ftp site image.vanderbilt.edu. I downloaded it but had few errors building on cygwin, if I have more time later I’ll try to port it to linux proper. In case this package goes away this is a saved copy morph.tar.Z , and this is the google search result which is the original post by Dr Peter announcing this package.