Q:

A part of an image is represented by an n x n matrix. After performing data compression and then data reconstruction techniques, the resulting matrix has values that are close to but not exactly equal to the original matrix

0

A part of an image is represented by an n x n matrix. After 

performing data compression and then data reconstruction techniques,

the resulting matrix has values that are close to but not exactly equal 

to the original matrix. For example, the following 4 x 4 matrix variable 

orig_im represents a small part of a true color image, and fin_im

represents the matrix after it has undergone data compression and 

then reconstruction.

orig_im =

 156 44 129 87

 18 158 118 102

 80 62 138 78

 155 150 241 105

fin_im =

 153 43 130 92

 16 152 118 102

 73 66 143 75

 152 155 247 114

Write a script that will simulate this by creating a square matrix of 

random integers, each in the range from 0 to 255. It will then modify 

this to create the new matrix by randomly adding or subtracting a 

random number (in a relatively small range, say 0 to 10) from every 

element in the original matrix. Then, calculate the average difference 

between the two matrices.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch13Ex8.m

% Simulates image compression and reconstruction, and 

% Calculates average difference between matrices

orig_im = randi([0 255],4,4);

[r, c] = size(orig_im);

offval = randi([-7 9],r,c);

fin_im = orig_im + offval;

avediff = mean(mean(abs(offval)));

fprintf('The average difference is: %f\n',avediff)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now