Hello.
Graduated with an Electrical Engineering degree in 1999. Decided to purse a part-time MBA this year and was given an option to do an Engineering Elective with a partner University and completely getting my behind kicked as a lot has changed in the two decades since I graduated. Never had Matlab when I graduated and my focus back then was Electrical Motors, so this is all very very new to me. Everything I've learnt is from Google and the MatLab documentation (I travel a lot for work and therefore don't have much on-campus resources), so my apologies if I've even gotten the basics wrong.
For the first part of the assignment (four parts total), I have to "read" and image into Matlab, determine the size of the matrix, calculate the uncompressed image size, save it as a JPEG with varying quality factors, calculate compression ratios, etc. etc. for a total of 15 sub-tasks. I'm using the image file posted here: https://imgur.com/WsEAGHf
Does the code I have so far appear correct? I've tried to comment on what each function is attempting to accomplish.
%Reading image into a matrix called LENA in Matlab
LENA = imread('lena-256x256.jpg');%Determining number of rows and columns of the matrix
[LENA_X, LENA_Y] = size(LENA);%Calculating uncompressed image size assuming each pixel is stored in one byte
LENA_uncompressed_image_size = LENA_X * LENA_Y;%Saving the image with different compression ratios of 95, 60, 30 and 5
imwrite(LENA, 'LENA_95.jpg', 'jpg', 'Quality', 95);imwrite(LENA, 'LENA_60.jpg', 'jpg', 'Quality', 60);imwrite(LENA, 'LENA_30.jpg', 'jpg', 'Quality', 30);imwrite(LENA, 'LENA_5.jpg', 'jpg', 'Quality', 5);
Here is what is stumping me. I am supposed to calculate the bit-rate of each compressed file using the formula BitRate = (FileSize / PixelCount). I'm unable to figure out how to read the file size of each image into Matlab. Additionally, they have stated that the original uncompressed file has a bit-rate of 8. Using the formula they have provided, and just using the "Size" in Windows as the file size (45577 bytes) and the pixel count (256×256 = 65536) I have no idea how to get 8 bits-per-pixel.
Any help is appreciated.
Thanks, Steve.
Best Answer