-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_gray.m
More file actions
38 lines (32 loc) · 1.08 KB
/
main_gray.m
File metadata and controls
38 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
clear all;
close all;
clc;
%% Prompt user and read image file.
prompt = 'Enter file name with extension (Example: cameraman.tif) : ';
filename=input(prompt, 's');
img = imread(filename);
figure;
imshow(img, []);
title("Input Image")
if length(size(img)) == 3 %if color img then covnerting into grayscale
img = rgb2gray(img);
end
%% Display file size of input image
imwrite(img,"input_img.jpg") % Saving image file locally
comp_name = "input_img.jpg";
comp_file=imfinfo(comp_name); % Getting file size of compressed image
comp_file_sz=comp_file.FileSize;
fprintf('File size of input image (in bytes): %f\n\n', comp_file_sz);
img = double(img);
%% Use lossy
disp("Lossy Grayscale Image:")
[comp_img, uncomp_img] = lossy_haar(img);
show_plots(img, uncomp_img, 'lossy');
compare_haar(img, comp_img, uncomp_img);
%% Use lossless
disp("Lossless Grayscale Image:")
[comp_img_ll, uncomp_img_ll] = lossless_haar(img);
show_plots(img, uncomp_img_ll, "lossless");
compare_haar(img, comp_img_ll, uncomp_img_ll);
%%Comparing with other methods
compare_diff_methods(img);